Computers and Technology

Description

Once these are done, create a class called Adventure and write the main method of your program in it (remember that the class that contains the main method is the one that you run). The first thing to do in main is to create a Player object and set its starting coordinates to (0,0). Also, you will need to create a new Map object. The idea in the Adventure class is that you loop repeatedly until the player dies (attacked by grue – see below) or finds the treasure (opens chest – see below). Every time the player moves, update the player's position and get the appropriate Room object from the map. Using this object, display the appropriate text to the user based on what command they type in. A list of commands is given below. Ignore case on the user input.

• GET LAMP – If the lamp is present in the current room (there is a method in the Room class (i. e. getLamp()) that allows you to check this. Note the method’s return type and assign the return value accordingly), this transfers the lamp from the room to the player. Be sure to clear the lamp from the room afterwards. Print "OK" if successful, or "No lamp present" if not. Note: that you can find the lamp in a dark room.

• LIGHT LAMP – If the player has the lamp, this sets it to lit. Print "OK" if successful, or "You don't have the lamp to light" if the player doesn't have the lamp.

• NORTH, SOUTH, EAST, WEST – If the current room (prior to the move) isDark(), AND the player doesn't have the lamp OR they have the lamp but the lamp is not lit, the player is eaten by a grue and the game is over. (see below for an example). Otherwise, move the user North one square (-1 x), South one square (+1 x), East one square (+1 y), or West one square (-1 y). See table below to understand x and y in the context of the map. Once you move into a new room, you should print out its description, so the user doesn't have to type LOOK every time. Be sure to check the current room object to see if the given direction is valid. If not, print ("Can't go that way"). If the room (after the move) isDark() AND the player does not have the lamp OR the lamp is not lit, then instead of printing the description, tell them: "It is pitch black, you can't see anything. You may be eaten by a grue!". (see below for an example)

• LOOK –If the room isDark() and the player does not have the lamp or the lamp is not lit, then instead of printing the description, tell them: "It is pitch black, you can't see anything. You may be eaten by a grue!". (see below for an example). Otherwise, this prints the description of the current room object, as well as any objects that are in the room. You should also print which exits from the room are valid. i. If the lamp is present in the room, print "There is an old oil lamp here that was made long ago" after you have printed out the room description. ii. If the key is present in the room, print "You see the outline of a key on a dusty shelf that's covered in dust." after you have printed out the room description. iii. If the chest is present in the room, print "There is a large, wooden, massive, oaken chest here with the word "CHEST" carved into it" after you have printed out the room description.

• GET KEY – If the key is present in the room, this transfers the key to the user's inventory. Be sure to clear the key from the room afterwards. Print "OK" if successful, "No key present" if not.

• OPEN CHEST – If the chest is present in the room and is unlocked, then this should print out the chest's contents and end the game. If the chest is locked, print "The chest is locked". If the chest is not present in the room, print "No chest present".

• UNLOCK CHEST – If the user has the key, call the use() method with the chest object to unlock it, then print "OK". If the user doesn't have the key, print "Need a key to do any unlocking!". If the chest is not present, print "No chest to unlock". • (anything else) – Just print "I'm sorry I don't know how to do that."

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
image
Computers and Technology, 23.06.2019 02:00, vivian2020
Read this excerpt from helen keller’s autobiography, the story of my life. have you ever been at sea in a dense fog, when it seemed as if a tangible white darkness shut you in, and the great ship, tense and anxious, groped her way toward the shore with plummet and sounding-line, and you waited with beating heart for something to happen? i was like that ship before my education began, only i was without compass or sounding-line, and had no way of knowing how near the harbour was. "light! give me light! " was the wordless cry of my soul, and the light of love shone on me in that very hour. . the morning after my teacher came she led me into her room and gave me a doll. the little blind children at the perkins institution had sent it and laura bridgman had dressed it; but i did not know this until afterward. when i had played with it a little while, miss sullivan slowly spelled into my hand the word "d-o-l-l." i was at once interested in this finger play and tried to imitate it. when i finally succeeded in making the letters correctly i was flushed with childish pleasure and pride. running downstairs to my mother i held up my hand and made the letters for doll. i did not know that i was spelling a word or even that words existed; i was simply making my fingers go in monkey-like imitation. in the days that followed i learned to spell in this uncomprehending way a great many words, among them pin, hat, cup and a few verbs like sit, stand and walk. based on this excerpt, which words best describe helen keller?
Answers: 2
image
Computers and Technology, 23.06.2019 03:00, Julianhooks
State 7 common key's for every keyboard
Answers: 1
image
Computers and Technology, 24.06.2019 12:00, elainnysanchez1541
How can we take picture in this app
Answers: 1
Do you know the correct answer?
Description

Once these are done, create a class called Adventure and write the main meth...

Questions in other subjects:

Konu
World Languages, 30.08.2020 19:01
Konu
Mathematics, 30.08.2020 19:01
Konu
History, 30.08.2020 19:01