Question: Directions: A student thought that his computer science class was boring and asked his teacher to incorporate games to the class (true story). In this
Directions: A student thought that his computer science class was boring and asked his teacher to incorporate games to the class (true story). In this lab, you are going to program a simple Tic-Tac-Toe game in Java, represented by a Game class. You are provided with a skeleton of the class on Canvas and you are to fill in the following methods: 1. int [] getMove( ) - Asks the user to enter a string of characters representing the coordinate where they wish to place their letter, returns an array of length 2 storing the row and column. For instance, 30 will return the array {3,0}. - If the space is already occupied by something other than an asterisk, it should tell this to the user and ask them for another location. - If characters other than 0 through 9 are in the string, it should tell the user to input only 09 and ask for their location again. - If the string has more than two characters (e.g. 351), it should display an error message and ask for their choice again. - If they enter a location not on the board (e.g. a board of side length 4 and the player enters 83), it should display an error message and ask for their choice again. 2. boolean detecthin() - checks horizhin(), verthin(), and diagWin(), if one of them is true, returns true. Otherwise, returns false. 3. boolean horizWin( ) - Detects a horizontal win (a full row of x 's or a full row of 0 's), returns true if detected, false otherwise. 4. boolean vertWin() - Detects a vertical win (a full column of X s or a full column of 0 's), returns true if detected, false otherwise. 5. boolean diagHin() - Detects a diagonal win (top left to bottom right OR top right to bottom left), returns true if detected, false otherwise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
