ElenaR1

Weapon.java

Apr 9th, 2019
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package bg.uni.sofia.fmi.mjt.dungeon.treasure;
  2.  
  3. import bg.uni.sofia.fmi.mjt.dungeon.actor.Hero;
  4.  
  5. public class Weapon implements Treasure{
  6.     private String name;
  7.     private int damage;
  8.    
  9.     public  Weapon(String n, int d) {
  10.         setName(n);
  11.         setDamage(d);
  12.     }
  13.    
  14.     public void setName(String n) {
  15.         this.name=n;
  16.     }
  17.    
  18.     public String getName() {
  19.         return this.name;
  20.     }
  21.    
  22.     public void setDamage(int d) {
  23.         this.damage=d;
  24.     }
  25.    
  26.     public int getDamage() {
  27.         return this.damage;
  28.     }
  29.    
  30.     @Override
  31.     public String collect(Hero h) {
  32.     //  if(h_attack<this.getDamage()) doesn't work ?
  33.         h.equip(this);
  34.         String a="Weapon found! Damage points: ";
  35.         int d=h.getWeapon().getDamage();
  36.         String b=Integer.toString(d);
  37.         return a+b;
  38.  
  39.     }
  40.  
  41. }
Add Comment
Please, Sign In to add comment