and i need help to this task. i am really stuck, i need help to move on
The Explorer’s backpack can contain up to 20 kg of small items. Large items cannot be carried in the explorer backpack (they cannot be picked up). Implement a method in the Explorer class that returns the total weight of all items in the backpack at a given moment.
An item can be picked up from the floor of the current room and added to the explorer’s backpack, or dropped on the floor (from the backpack).
In Explorer class implement the following method:
public boolean pickup(Item someItem)
the method returns true if the item was picked up successfully, false otherwise (for example if the backpack was already full).
In Room class implement:
public boolean drop(Explorer expl, String itemName)
the method returns true if the item is in the backpack and can be successfully dropped in the room, false otherwise.
Use these new methods in the Game class, by adding 2 new commands to the textual menu:
“Welcome to the BlaBlaBla game. Type: ‘a’ to add a random item to the room ‘r’ to remove the first item in the room’s item list ‘l’ to print a list of all items in the room ‘p’ to pick up an item from the room ‘d’ to drop an item from backpack to the room ‘q’ to quit the game.”
And make it so that at each turn, the Game class prints also the list of contents of the explorer’s backpack. When the player types ‘p’ the game should list the items in the room and ask the name of the item to pick up.
Beware: there could be 2 items with the same name, or none; please be sure that your pick up command works for both and eventually prints relevant messages to the player in both cases.
Aucun commentaire:
Enregistrer un commentaire