Modeling in Java Mini Project Class Design – Chess Game Due Wednesday Nov 16 2005 by jef20128


									                                     Modeling in Java: Mini Project
                                      Class Design – Chess Game
                                     Due Wednesday, Nov 16, 2005

Your assignment is to create a design for modeling a game of chess. If you will recall, the game of chess
is played between two players (one with white pieces and one with black pieces) with the goal being to
eliminate the other person’s pieces and place his King in “checkmate”. Each player has 16 pieces (1
King, 1 queen, 2 bishops, 2 rooks, 2 knights, and 8 pawns) which can move as follows:
     King – one square in any direction
     Queen – as many squares as she wants in a single straight line.
     Rook – vertically or horizontally as many squares as it wants
     Bishop – diagonally as many squares as it wants.
     Knight – in an “L-shape” 2 squares either horizontally or vertically, then one square at a right
        angle to the first motion.
     Pawn – One square directly towards the opponent’s side of the board. Except that the pawn can
        only take pieces one square diagonally towards the opponent’s side of the board. And, on its first
        turn the pawn has the choice of moving either one square or two.

The game board consists of an 8 x 8 square of alternating white and black pieces. The initial setup has the
back row with the King and Queen in the center, bishops beside them, then knights and then rooks. The
second to last row consists of all 8 pawns.

Finally, the game begins with the first move by the player with the white pieces.

Your job is to model the game using a set of Java classes. You need to be very complete with your
model. I should be able to completely code this problem by the model that you turn in.

As you are doing it, remember that you must account for both things and actions in your design (things
become objects/variables and actions become the methods and communication relationships among those
objects). Make sure to really think about the objects you are creating and what information each of them
knows. Then think about what information they need to get from elsewhere and what actions they must

Define the variables each object contains (name and data type). Define the method signatures for each
object. Also take a crack at defining and writing pseudo-code for any relevant constructors and the
methods for each object as well (you don’t need to get all of them, just a representative sample). Use
UML-style diagrams to model the classes.

length: int
artist: String
album: Album
play() : void
getLength(): double
getName(): String
setAlbum(Album a): void
Song(String name, double length, String artist, String albumName)

To top