Exercises appear at the end of lesson. Many of the exercises have you build pieces of an application that plays the game of chess. If you are unfamiliar with the rules of chess, you can read them at http://www.chessvariants.com/d.chess/chess.html.
As with Student, you will start simply by creating a class to represent a pawn. First, create an empty test class named PawnTest. Run JUnit against PawnTest and observe that it fails, since you haven't written any test methods yet.
Create a test method named testCreate. Ensure that you follow the correct syntax for declaring test methods.
Add code to testCreate that instantiates a Pawn object. Ensure that you receive a compile failure due to the nonexistent class. Create the Pawn class and demonstrate a clean compile.
Assign the instantiated Pawn object to a local variable. Ask the pawn for its color. Code a JUnit assertion to show that the default color of a pawn is represented by the string "white". Demonstrate test failure, then add code to Pawn to make the test pass.
In testCreate, create a second pawn, passing the color "black" to its constructor. Assert that the color of this second pawn is "black". Show the test failure, then make the test pass. Note: Eliminate the default constructorrequire that clients creating Pawn objects pass in the color. The change will impact the code you wrote for Exercise #4.
In testCreate, create constants for the Strings "white" and "black". Make sure you rerun your tests.