You are on page 1of 2

Object Oriented Adventure Game Lab

A. Visit my adventure. Run the Adventure Game Find My Keys code from Moodle and
play the game at least twice. Answer these questions:
1. List the classes that are defined in this code. Room and House
2. For each class, list the methods that are defined in this code. describeDoor,
describeRoom, setIsKeyHere, getRoomName
3. How do we start playing the game? Is that function a method in a class?
playGame() it is not a method
4. What makes the game stop? Under what condition does the while loop exit?
Finding the keys makes it stop, when done = true
5. For the House class, what are the parameters for the __init__ method (constructor)?
(self,roomList,doorList)
What attributes are set in the constructor?
self.roomList = roomList
self.doorList = doorList
6. For the Room class, what are the parameters for the __init__ method (constructor)?
(self,roomName,description,doorList)
What attributes are set in the constructor?
self.roomName = roomName
self.description = description
self.doorList = doorList
self.isKeyHere = false
7. Explain what each line of the describeDoors method for a room does.
Line one defines the basic door description.
Line two starts a for loop for the number of doors.
Line three modified the door description
The last line returns the description.
8. What Boolean variables are used in this code? On which line of code is each one
initialized?
isKeyHere has a Boolean variable and is located on line 20
B. Pictures and Sounds. Turn in your finished code after completing this part.

First, change my code to add sound and picture attributes to the room class.
1. In the room class, change the __init__ method to add two more parameters for sound
and picture. Make two new attributes called roomSound and roomPic, and set their
values in the constructor.

2. In the main program at the top of the code, set the media path. Then make a sound
object and a picture object by giving the name of a file for each one. For now, we’ll
just use one sound and one picture for all the rooms. Use a small picture, such as arch
or Barbara. Add that sound object and picture object to each of the constructors for
the five rooms in my house.

3. Run the code. It should run as before.

Now show the pictures and play the sounds.


1. Write a new method in the room class called enterRoom. In this method, place calls
to print the description, show the picture, and play the sound.

2. Instead of calling location.describeRoom() from the main program, call the


enterRoom method.

3. Run the code. Now each time you enter a room, the picture should display and the
sound should play.

C. Design your own adventure game


1. What theme will you have?
Man escaping a sinking ship.
2. What is your floor plan? (between 5 and 10 rooms)

3. What enhancement are you thinking of creating?


You must collect three things, and the ending changes depending on if you have them
all.
4. Write a short paragraph about your game.
The basic idea is to expand the base “find the keys” game, but you will find several items
instead of just one. These will be a flare gun, a lifejacket, and an inflatable life raft. You
can leave before collecting all of them, but it will change the outcome.
Turn in your design. You may either sketch something with a paint program, or submit a
picture of a hand-drawn design.