-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeaponModel.java
More file actions
66 lines (56 loc) · 1.52 KB
/
WeaponModel.java
File metadata and controls
66 lines (56 loc) · 1.52 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package org.example.models;
import org.example.enums.*;
public class WeaponModel {
private Weapons weaponName;
private int cost;
private int combatValue;
public WeaponModel(Weapons weapon) {
this.weaponName = weapon;
setCostAndValue();
}
private void setCostAndValue() {
switch (weaponName) {
case FIST:
this.cost = 0;
this.combatValue = 1;
break;
case KNIFE:
this.cost = 1000;
this.combatValue = 2;
break;
case SNIPER:
this.cost = 10_000;
this.combatValue = getCombatValue();
break;
case KALASHNIKOV:
this.cost = 20_000;
this.combatValue = getCombatValue();
break;
}
}
public int getCombatValue() {
return combatValue;
}
public void setCombatValue(double distance) {
if (weaponName == Weapons.SNIPER) {
if (distance > 1000) {
combatValue = 4;
} else {
combatValue = 3;
}
} else if (weaponName == Weapons.KALASHNIKOV && distance <= 1000) {
combatValue = 4;
} else {
combatValue = 3;
}
}
public int getCost() {
return cost;
}
public Weapons getWeaponName() {
return weaponName;
}
public void setWeaponName(Weapons weapon) {
this.weaponName = weapon;
}
}