As you know from the pre-lab, we are working with a game called Othello. The makers of Othello have an interesting catchphrase: “A minute to learn, a lifetime to master.” In this lab, we provide you with a working, text-based version of the game.
The code we provide is almost complete. You have to write one (relatively) simple method to make the code work. However, we will focus on using JUnit, a Java framework for unit testing that is built into Dr Java as well as many other tools.
Copy the Othello project. A complete set of source files project for the Othello game can be found in Lab6.zip. Extract these files to folder named Lab6 on the student drive. As always, open Dr Java and create a project file named Lab6. Open/save each Java source file in the project and save the project. Use the menu Project->Compile Project to compile all the files.
Run the project. Select the file Game.java in the side panel and use the Tools->Run Document’s Main Method Note what happens for your project report.
Look at the inRange method of the Board class. This is the method that you will be writing. The existing code is a “Stub” that always provides the return value false. The method is supposed to verify that a given position on the board is valid. If row and column are the number of rows and columns on the board, then a position (testRow, testCol) is in range iff:
0 ≤ testRow < row and 0 ≤ testCol < column
Write a test class and a test method for the Board class. Our strategy will be to write the test case first, then write the method. We will use Dr Java to do this.
Run the tests. Use the menu Tools->Test Current Document to run your test cases. They should fail. If they all pass with the provided stub version of the Board inRange method, then your test cases are not very good. Add test cases until at least some of them do fail.
Write the inRange method. Continue the following two steps until all test cases succeed.
Play Othello and enjoy. Open the lower Interactions window so that you will be able to see the entire game board area. Select the Game.java file in the sidebar and use menu Tools->Run Document’s Main Method. If you have implemented and tested your implementation of Board inRange well, the game should work correctly.
Write a document describing your experiences. Your lab must be printed (not handwritten).
Answer the following questions related to what you did in this week’s lab.