-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeapon.java
More file actions
43 lines (37 loc) · 869 Bytes
/
Copy pathWeapon.java
File metadata and controls
43 lines (37 loc) · 869 Bytes
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
public class Weapon {
private final String name;
private int damage;
private int value;
public Weapon(String newName){
name = newName;
setDamage(newName);
setValue(newName);
}
public String getName(){
return name;
}
public int getValue(){
return value;
}
public void setValue(String name){
switch (name) {
case "Bronze Sword" -> value = 10;
case "Wooden Sword" -> value = 5;
case "Silver Sword" -> value = 15;
case "Diamond Sword" -> value = 17;
}
}
public void setDamage(String name){
switch (name) {
case "Bronze Sword" -> damage = 10;
case "Wooden Sword" -> damage = 5;
case "Silver Sword" -> damage = 20;
case "Diamond Sword" -> damage = 25;
case "Teeth" -> damage = 12;
case "Axe" -> damage = 15;
}
}
public int getDamage(){
return damage;
}
}