Question
Can someone help me code my items class also my extended classes as well like items extends weapon, armour, craftedItems, etc below is also my
Can someone help me code my items class also my extended classes as well like items extends weapon, armour, craftedItems, etc below is also my player class that i have code that realtes to items if someone could please help as soon a spossible im having some trouble
public class Player { // instance variables - replace the example below with your own private Stack
/** * 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 < 1; } }
Weapon Item + damage: int +name: String + description: String + Weapon(String, String, int): Weapon + getDamage): int Armor + hp: int + Item(String, Strinng): Item + getName:String +getDescription(): String +getWeight0: int Extends +Armor(String, String, int): Armor +getHp): 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 Item + damage: int +name: String + description: String + Weapon(String, String, int): Weapon + getDamage): int Armor + hp: int + Item(String, Strinng): Item + getName:String +getDescription(): String +getWeight0: int Extends +Armor(String, String, int): Armor +getHp): 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): CraftedltemStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started