©2005 Felleisen, Proulx, et. al.
Refer to Problem 2.3 and Problem 3.9 from Assignments 2 and 3.
Design the methods that computes the maximum money the player can win, when starting with the given amount.
Design the methods that determines whether two rooms are the same. Two wizard rooms are considered the same if they use the same formula to compute the reward.
Design the method nextMove
for the class that represents the
girl player. The method produces a new girl player. If the game is
over, the method just returns the girl player unchanged. Otherwise,
the girl's fortune is either increased by the elf or a wizard, or
plundered by the monster. The method consumes a
String
"left" or String
"right" that determines the choice of doors, left or right,
and the player moves to that room. The player should not move anywhere, if
the input is different from these two values. Of course, there are no
doors in the wizard room.
Design the methods that draw the three different rooms for the Maze
Game, i.e. the Monster
room, the Elf
room, and the
Wizard
room in the
World
. They can be just rectangles of different color, but
you may use some creativity along the way.
This problem will not be graded, but you need some graphical representation of the different rooms to proceed with the rest of the problems.
Design the methods that draw some representation of the amount of money the girl player has. It can be as simple as a yellow circle of increasing or decreasing radius, or a fancy pile of gold nuggets.
This problem will not be graded, but you need some graphical representation of the money to proceed with the rest of the problems.
Add the girl player to the World. Define the two methods needed to
play the interactive game -- draw
and move
and
onKeyEvent
.
The draw
method should paint some background, draw the
current fortune of the girl player, and draw the room where the player
is currently.
The move
method produces a new World
with the player
that has made the next move, given a String
with values
"left" or "right" as its argument. If the argument
is not one of these two strings, the world remains the same.
The onKeyEvent
method takes one argment, a String
that represents the key that has been hit. The left and right arrow
keys are represented by String
s "left" and
"right". This method just invokes the above move
method
with the argument it received.
You shold now be able to play the game.