Starting from:
$30

$24

Recitation 8 - Java Object Model Solution

Notify your Recitation TA once you have completed this recitation so that they may verify your work.




Recitation Goal: in this recitation you will implement appropriate hashCode and equals methods to make a simple board game application function correctly.










Recitation Setup




To start, download the Recitation8.zip ZIP file. Open NetBeans and using FileImport ProjectFrom ZIP, import the project contained in the ZIP file. You should end up with a Recitation8 project, containing a package boardgame, which is a framework for implementing simple board games, a package tictactoe, which is an implementation of the game of Tic-Tac-Toe using the framework, and a package tictactoe.textui which is a textual user interface for the Tic-Tac-Toe game.




Introduction




Look over the classes in the boardgame framework, to get an idea of what is provided there.




Look over the classes in the tictactoe package, including the tictactoe.textui package, to get an idea of how they relate to the classes in the boardgame framework.




Launch the TicTacToe game by running the TextualTicTacToeGame class. Enter "X" or "O" in response to the initial prompt. When prompted for a move, the game is expecting you to enter a move in the form "(r,c)" (no spaces), where r is the row number and c is the column number, starting from 0. You will notice that the game does not work: moves that you type are

never accepted as legal.










Recitation Requirements




The reason the TicTacToe game fails to function properly is because there are some classes that have neglected to properly override equals and hashCode. Identify these classes and

provide proper implementations of these methods. A good place to start is to use the debugger to step through the chooseMove method in the InteractiveMover class.










When you are done, demonstrate your working game to one of the TAs.

More products