-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeapon.java
50 lines (41 loc) · 1.27 KB
/
Weapon.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class Weapon extends Product{
private int damage_val;
private int req_hands;
// initialize the Product;
public void initialize(String n, double p, int l, int d, int h) {
super.initialize(n, p, l);
setDamage_val(d);
setHands_num(h);
}
// set damage value;
public void setDamage_val(int d) {
damage_val = d;
}
// set the needed hands number when using the weapon;
public void setHands_num(int h) {
req_hands = h;
}
// return the damage value
public int getDamage_val() { return damage_val;}
// return hands number;
public int getHands_num() { return req_hands;}
// use waepon on monster;
public void use(Monster m){
m.beAttacked(damage_val);
}
@Override
// print the title of the information of the weapons;
public void print_title() {
System.out.println("Name\tPrice\tRequired Level\tDamage\tRequired Hands");
}
@Override
// print the information of the weapons;
public void print_info(){
System.out.println(getName() + "\t" + getPrice() + "\t" + getLevel() + "\t" + damage_val + "\t" + req_hands);
}
@Override
// return the type --- weapon;
public String get_type(){
return "Weapon";
}
}