Name: ________________
ID:_______________
Here is the description of Othello that appeared above.
Othello is a two-person game played on an eight-by-eight board. It is often convenient to number the rows of the board 1-8 and the columns A-H. The game begins with two black pieces and two white pieces on the center four squares of the board (D4, D5, E4, and E5). There is a black piece in the top-left and bottom-right of those four squares (D4 and E5). There is a white piece in the top-right and bottom-left of those four squares (D5 and E4). Players alternate turns, with each player making a legal move when it is his or her turn. A legal move consists of placing a piece so that two of pieces surround a row, column, or diagonal of the opponent's pieces. All of the opponent's pieces are then flipped (from black to white or from white to black). If a player cannot make a legal move, that player loses his or her turn. Play continues until there are no longer blank squares on the board or neither player can make a legal move. The player with the most pieces is the winner.
Step 1. Circle all of the nouns.
Step 2. For each noun, decide whether that noun represents something you need to represent in the program or something not necessary to the program. If the noun represents something necessary to the program, decide whether it is an object or a class. If the noun represents something unnecessary, suggest why.
Step 3. Box all of the verbs.
Step 4. For each verb, decide whether the verb represents a method a class might implement. Then attach each verb to the appropriate class or classes.
Step 1. Reread the description of Othello and make a list of at least two new questions of the form ``who does this?'' What additional objects or classes, if any, do the answers to these questions suggest?
Step 2. Look at your list of methods and, for each method, ask ``What information do I need in order for this method to succeed?'' Make a list of methods and their required pieces of information.
Step 3. Look at the required pieces of information you developed in step 2 and for each piece decide whether it is more appropriately a parameter to the method or a field in the object.
Step 4. Consider each of the classes you developed in this experiment and in Experiment O1.1. For each class, consider what fields you will need. This may require you to reflect on how you would normally describe the object or on how the object operates.
Step 1. Based on your analysis of Othello, create a
Move
class. Your class need only include fields, constructors,
and empty methods. You need not enter the bodies of any methods
you include. Summarize the design of your class.
Step 2. Based on your analysis of Othello, create a
Board
class. Again, include only fields, constructors,
and empty methods. Summarize the design of your class.
Step 3. Based on your analysis of Othello, create a
Rules
class. Once again, include only fields, constructors,
and empty methods. Summarize the design of your class.
Step 1. Write a narrative describing the interaction with
the Game
object at the end of a game. You may need to play
a game of Othello by hand to reach an end state, or you may find it
appropriate to make one up. Try to consider other aspects of the rules
as you write this narrative. Your narrative should be between one hundred
and two hundred words.
Step 2. The original interaction narrative (the one describing the beginning of the game) is woefully lacking in details, as is illustrated by the questions we asked earlier. For example, it does not describe how the board is displayed or how input is read from the players. Rewrite the narrative so as to clarify these issues. Your new narrative should be approximately two hundred words.
Step 3. Expand your narrative from Step 1 to include more details, as suggested in step 2.
Step 4. Pick at least two new classes, methods, method parameters, or fields suggested by these narratives, and update your code from the previous experiment to include the updates. Enter your changes here.
Step 1.
Earlier, we developed pseudocode for a game of Othello. Translate this
into Java code. In particular, create an Othello
class
with a main
routine that corresponds to this pseudocode.
Your main
routine should contain real Java code, although
it need not work yet (since the other classes are unlikely to be
complete).
Step 2.
Consider whether any of the pieces of the main
routine
would be better represented as separate objects or methods. Enter
your suggestions here.
Step 3.
Write a makeMove
method for the Player
class.
Your method will need to prompt for the move to make and return a
corresponding Move
. Describe your algorithm here.
Step 1.
Make a list of eight method calls that might appear in an implementation
of an Othello game. For each call, note which method of which object
would make the call and which object would provide the called method.
For example, it is likely that the main
method of
OthelloGame
will call the display
method
of Board
.
Step 2. Draw a picture showing the interactions between the objects described in step 1. Feel free to use whatever form you deem most appropriate.
Step 1. Describe an interesting alternate board on which we might play Othello.
Step 2. Suggest an alternate game (other than chess) in which we might use the Othello board.
Step 3. What other classes will need to be changed if we play Othello on different boards? Why?
Step 4.
What does this suggest about the design of the Board
class
in your Othello game? In particular, what fields are truly needed, and
what belong in subclasses? More importantly, what methods should
Board
s include?
[Front Door] [Introduction] [Code]
Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.
Source text last modified Tue Oct 26 10:40:18 1999.
This page generated on Tue Oct 26 15:36:57 1999 by Siteweaver.
Contact our webmaster at rebelsky@math.grin.edu