Assigned | Friday, March 1th |
---|---|
Program Due | Friday, March 15th by 2:00am |
Weight | 7% |
Updates |
To gain experience in the following areas.
For this project, we will be coding a text based version of Connect Four. If you are unfamiliar with the game, please go here to learn more: http://en.wikipedia.org/wiki/Connect_Four
You will be creating three classes: Project2.java, ConnectFour.java, Move.java. Descriptions are below:
An invalid move should cause the menu to reprompt the player for their move.
ConnectFour.java should contain the board state and which player's turn it is. The ConnectFour object should be able to allow the currnet player to move, report on whether the game has ended or not, and convert itself to a string for the purpose of display. When storing the board, use the Move enum to ensure that the player's moves are all in a valid state. For example, if you choose to represent the board as a two dimensional array, you should make that array of type Move to ensure that the only valid values for a space are PLAYER1, PLAYER2, or EMPTY. Note that a board that has an area of less than 25 spaces should be considered invalid, and you should include the following line: throw new RuntimeException("Invalid board size");
This enum represents a state at a given position on the board. It can take on the values PLAYER1, PLAYER2, or EMPTY.
ConnectFour should have a main class with a test for all major functions showing they work with a variety of inputs.
Welcome to ConnectFour! At any time you may press Q to exit! Please enter player one's name: Max Morawski Please enter player two's name: Susan Mitchell How many rows would you like? 10 How many columns would you like? 10 __________ __________ __________ __________ __________ __________ __________ __________ __________ __________ Max Morawski, where would you like to move? 0 __________ __________ __________ __________ __________ __________ __________ __________ __________ X_________ Susan Mitchell, where would you like to move? 1 __________ __________ __________ __________ __________ __________ __________ __________ __________ XO________ Max Morawski, where would you like to move? Q Exiting.