subject

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."

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 13:30
Hola, me podrian resolver estos ejercicios en php? ejercicio1: crear una pagina que permita realizar una conversion monteria: nuevos soles, dolares, euros. se debe seleccionar el valor monetario origen y conversion asi como tambien el monto a convertir ejercicio2: crear un pagina que muestre la tabla de sumar de un rango de numeros ingresados por teclado. ejercicio3: ingresar una palabra y mostrar la escritura del final al inicio ejercicio4: ingresar la fecha de nacimiento de una persona y determinar, cuantos años, meses y dias tiene ejercicio5: ingresar un rango de valor numerico y mostrar, los numeros pares, impares y primos.
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
You know the right answer?
Description

Once these are done, create a class called Adventure and write the main meth...
Questions
question
Mathematics, 21.06.2019 19:10
question
Mathematics, 21.06.2019 19:10
question
Mathematics, 21.06.2019 19:10
Questions on the website: 13722363