Pick a game and write a short two paragraph description of the game comparable to the description of Othello from this laboratory. Using this description, identify the objects and classes that might be used in a simulation of that game.
We are on our way to a working Othello game. The first step is to get a working interface. You will need
Othello
,
Rules
, Player
, Board
,
and Piece
. A framework contains only class definition,
constructors (possibly empty) and methods (again, possibly empty).
You may have written some of these frameworks for
Experiment O1.3. When a method needs to return
a value, return a ``reasonable'' default value. For example,
the isLegal
method of the Rules
class
might always return true
.
Othello
class with a main
routine.
You may have written this for Experiment O1.5.
makeMove
method for the Player
class
that prompts for a move and returns a corresponding Move
object.
You may have written this for Experiment O1.5.
display
method for the Board
class.
You will need to write that now.
initialize
method for the Rules
class
that places pieces on the board. You will need to write that now.
By filling in the details, you should be able to get a simple working interface for the Othello game in which players can enter moves and see a board. At this point, the pieces should not flip and may not even display.
Note that as you fill in the details, you may realize that you need
additional methods. For example, although we have not discussed it,
the Board
class will clearly need a placePiece
method.
Board
Update the Board
class so that it will remember where pieces
are placed on the board and display them appropriately.
Rules
Finish the Rules
class. You will need to ensure that it is
able to
This problem is perhaps the most difficult in this assignment.
Using your code from the previous problems, update Othello so that it is played on a rectangular 6x8 board. What classes did you need to change?
Using your code from the previous problems, update Othello so that the initial state of the board contains two black pieces and two white pieces on the center four squares, with the black pieces forming a row and the white pieces forming a row. What classes did you need to change?
Using your code from the previous problems, update Othello so that pieces have three colors: white, black, and red. Assume that they flip in sequence: white to black, black to red, red to white. What classes did you need to change? What other questions did you need to ask in order for these updates to be successful and useful?
[Front Door] [Introduction] [Code]
Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.
Source text last modified Tue Oct 26 13:17:44 1999.
This page generated on Tue Oct 26 15:37:43 1999 by Siteweaver.
Contact our webmaster at rebelsky@math.grin.edu