Assigned Date: Tuesday, Jan. 31, 2006
Due Date: Tuesday, Feb. 7, 2006
Due Time: 11:55pm
Last modified on February 06, 2006, at 10:02 AM (see updates)
This assignment focuses on Unit Testing. You are expected to work in isolation (without access to any resources other than the class textbook, class notes, and the instructor).
Below you will find an OO design of Java classes for the game Tic-Tac-Toe.
Implement a test suite for diagnosing bugs in the future system implementation.
In the spirit of test-first development, do not implement the Tic-Tac-Toe game at this time.
- First create a stubbed implementation of the given OO design.
- Again, do NOT implement the complete functionality.
- Within your classes, provide only method signatures, and empty bodies (for void methods) or dummy return statements (for non-void methods).
- Using BlueJ's jUnit functionality, implement your tests as jUnit test classes and methods.
- Focus on functional cohesion, i.e., a test method should focus only one bit of functionality. The smaller, the better.
Your program stub should be implemented using BlueJ. Create a project called, what else,
TicTacToe. In that project create the following classes and stub methods:
Rules – encapsulates all rules of the game
public boolean isGameOver(Board board) - checks if the game is over
public boolean isWin(Board board) - checks if we have a winner
public boolean isDraw(Board board) - checks if we have a draw
public boolean isValid(int move, Board board) - checks if the proposed move is valid (it does not make the move)
HumanPlayer – encapsulates the human player
public void makeMove(Board board, Rules rules) - asks the end-user for a move and, if valid, puts it on the board
ComputerPlayer – encapsulates the computer player
public void makeMove(Board board, Rules rules) - uses artificial intelligence techniques to make a valid move (this functionality will be provided)
Board – encapsulates the game board
public Board() - builds a board of nine squares
public Board(int numOfSquares) - builds a board of
public void clear() – initializes the board to empty squares
public char getSquare(int position)
public void setSquare(int position, char value)
public String toString() - returns a printable representation of the board
public char getValue()
public void setValue(char value)
public String toString() -- returns a printable representation of the square
TicTacToe – the system driver
public static void main(String args) - declares instances of above classes and uses their methods to implement the game (again, this should be a stub for now)
Your test methods should be documented via javadoc. One should look at your javadoc API to determine the extent of your test suite.
- Open your BlueJ project.
- Open (edit) each source file and generate the class interface (javadoc). This can be done within the editor window either by pressing CTRL/J , or selecting the Interface drop-down menu item (on the right). (Note: This is necessary to generate your documentation for grading.)
- Under the Project menu, click Create Jar File... . In the dialog box that opens, select Include Source, and press Continue.
- Verify that the
.jar file is correct, by using the '
jar xvf file.jar' command, where
file.jar is your archive. Your
.jar file should contain:
Readme.txt (see Widget for a sample).
- Any files generated automatically by BlueJ (e.g.,
- A doc subdirectory with the Javadoc API documentation generated by BlueJ, for each of the classes above.
- Unit test classes for each class above.
In other words, I should be able to unzip your submission and run it without modifications or additions.
- Email the generated
.jar file to firstname.lastname@example.org, by the due date and time.