-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weapon.java
77 lines (70 loc) · 1.63 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* The Weapon class creates a weapon that Robots use on one another.
* The Weapon contains attributes such as name, damage, and range.
*
* @author Akshara Ganapathi, Mukund Ramachandran, Sanjeet Verma
* Collaborators: None
* Teacher Name: Ms. Bailey
* Period: 03/05
* Due Date: 05-19-22
*/
public class Weapon implements Comparable<Weapon> {
private final String name;
private final int damage;
private final int range;
/**
* Creates Weapon object
*
* @param name given name
* @param damage given damage
* @param range given range
*/
public Weapon(String name, int damage, int range) {
this.name = name;
this.damage = damage;
this.range = range;
}
/**
* Returns Weapon name
*
* @return Weapon name
*/
public String getName() {
return name;
}
/**
* Returns Weapon damage
*
* @return Weapon damage
*/
public int getDamage() {
return damage;
}
/**
* Returns Weapon range
*
* @return Weapon range
*/
public int getRange() {
return range;
}
/**
* Compares Weapon to other Weapons
*
* @param other other Weapon
* @return whether it is greater based on damage
*/
@Override
public int compareTo(Weapon other) {
return this.damage - other.damage;
}
/**
* Displays String representation of Weapon
*
* @return String representation
*/
@Override
public String toString() {
return name;
}
}