package AdventureGameModel; import java.io.Serializable; import java.util.ArrayList; /** * This class keeps track of the progress * of the player in the game */ public class Player implements Serializable { /** * The current room that the player is located in */ private Room currentRoom; /** * The list of items that the player is carrying at the moment */ public ArrayList inventory; /** * Adventure Game Player Constructor */ public Player(Room currentRoom) { this.inventory = new ArrayList(); this.currentRoom = currentRoom; } /** * This method adds an object into players inventory if the object is present in * the room and returns true. If the object is not present in the room, the method * returns False * * @param object name of the object to pick up * @return True if picked up, False otherwise */ public boolean takeObject(String object){ if(this.currentRoom.checkIfObjectInRoom(object)){ AdventureObject object1 = this.currentRoom.getObject(object); this.currentRoom.removeGameObject(object1); this.addToInventory(object1); return true; } else { return false; } } /** * checkIfObjectInInventory * __________________________ * This method checks to see if an object is in a player's inventory * * @param s the name of the object * @return True if object is in inventory, False otherwise */ public boolean checkIfObjectInInventory(String s) { for (int i = 0; i getInventory() { ArrayList objects = new ArrayList<>(); for (int i=0;i