Now it is time to code your game. Create a program to play the game you designed with only one player. Some criteria:
It needs to report the final score.
It needs to involve the player by asking if the player wants to continue and explaining the the player what is happening. If a piece moves, it must tell the new location. If a dice is thrown or a card picked, it must tell the player the dice roll or card pick.
Place the non-random portion (usually the movement) into methods separate from the random number generation so that the movement can be tested.
Include at least 4 test cases of every method that does not
generate a random number. These should be coded with junit so they
can be run without running the entire game. See instructions below
on how to install unit tester.
------
See the original game design assignment
------
upload to "board game for one player, perhaps without cards
Assignment" moodle assignment.
---
How to install unit tester:
Right click on your class in bluej. If "create test class" is an
option, click it. If not, click on tools/ preferences and then
interface and choose "show unit testing tools". Now right click on
the class and see "create test class". Click it.
Double click the test class that "create test class" creates. If
it has "import tester.*;" then you are done. If not, create
another folder inside your project folder called +libs, with the
plus sign. Download this tester jar file
and save it into that new folder. You will need to right click on
the link and save target as into +libs. You will then be able to
replace the code in your test class with the following template:
import tester.*;
/**
* Testing class --- your class name + Test
*
* @author (your name)
* @version (a version number or a date)
*/
public class YourClassPlusTheWordTest
{
// Instance variables go here, typically
examples to test.
// For example, if you're testing the Date
class, you might say
// private Date myBirthday = new Date(1964, 1,
27);
// private Date millennium = new Date(2001, 1,
1);
/**
* Run all test methods in the class.
*/
public static void testEverything ()
{
Tester.run (new
YourClassPlusTheWordTest ());
}
/**
* A sample testing method
*
* @param t the Tester to use
*/
public void testSomething (Tester t)
{
// put your code here,
e.g.
// t.checkExpect
(this.myBirthday.getYear(), 1964);
// t.checkExpect (new
Date(1941,12,7).addDays(10),
// new
Date(1941,12,17));
}
}