Question: Can someone help me code this in java below is my player class i need help coding my items, bag, weapon, armour , and cratedItem

Can someone help me code this in java below is my player class i need help coding my items, bag, weapon, armour , and cratedItem class below is my diagram of how it should be

public class Player { // instance variables - replace the example below with your own private Stackrooms; private String name; private ArrayList items; private int maxVolume; private int hp; private int damage;

/** * Constructor for objects of class Player */ public Player(String name) { // initialise instance variables this.name = name; }

public Room getCurrentRoom() { // put your code here return rooms.peek(); } public void goBack() { this.rooms.pop(); } public void goNext(Room room) { this.rooms.push(room); } public Item getItem(String name) { for(Item i : items) { if(i.getName().equals(name)) { return Item; } } } public pickUp(Item item) { if(item instanceof Armor) { Armor armor = (Armor) item; hp += armor.getHp(); } else if(item instanceof Weapon) { Weapon weapone = (Weapon) item; damage += damge.getDamage(); } else if(item instanceof Bag) { Bag bag = (Bag) item; maxVolume += bag.getWeight(); } items.add(item); } public Item drop(String name) { for(Item item : items) { if(item.getName().equals(name)) { if(item instanceof Armor) { Armor armor = (Armor) item; if(hp > armor.getHp()); { hp -= armor.getHp(); items.remove(armor); return armor; } } else if(item instanceof Weapon) { Weapon weapon = (Weapon) item; damage -= damage.getDamge(); items.remover(weapon); return weapon; } else if(item instanceof Bag) { } else { items.remove(item); return item ; } } } return null; } public boolean takeDamage(int damage) { this.hp -= damage; return this.hp

Can someone help me code this in java below is my player

Weapon +damage: int Item name: String + description: String + Weapon(String, String, int): Weapon +getDamage): int Armor we tem(String, Strinng): Item + hp: int + getName: String Armor(String, String, int + getHp): int Armor getWeight): int Bag Extends + volume: int Bag(String, String, int): Bag + getVolume(): int Extends Crafteditem + firstltem: Item + secondltem: Item Craftedltem(String, String, Item first, Item second): Craftedltem Weapon +damage: int Item name: String + description: String + Weapon(String, String, int): Weapon +getDamage): int Armor we tem(String, Strinng): Item + hp: int + getName: String Armor(String, String, int + getHp): int Armor getWeight): int Bag Extends + volume: int Bag(String, String, int): Bag + getVolume(): int Extends Crafteditem + firstltem: Item + secondltem: Item Craftedltem(String, String, Item first, Item second): Craftedltem

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!