forked from kishanrajput23/Java-Projects-Collections
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheory.java
130 lines (115 loc) · 2.99 KB
/
Theory.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Theory.java : stores values for weapon, location, and person
*
* @author Nery Chapeton-Lamas (material from Kevin Lewis)
* @version 1.0
*
*/
public class Theory {
private int weapon;
private int location;
private int person;
/**
* Full constructor, specifying each part of theory
*
* @param weapon
* integer representing weapon
* @param location
* integer representing location
* @param person
* integer representing person
*
* @see TheoryItem for values
*/
public Theory(int weapon, int location, int person) {
this.weapon = weapon;
this.location = location;
this.person = person;
}
/**
* Copy constructor, deep copies Theory object
*
* @param other
* used to get all theory parts and deep copy
*/
public Theory(Theory other) {
this.weapon = other.weapon;
this.location = other.location;
this.person = other.person;
}
/**
* Accessor for weapon value
*
* @return weapon integer value
*/
public int getWeapon() {
return weapon;
}
/**
* Mutator for weapon value
*
* @param weapon
* integer value representing weapon
*/
public void setWeapon(int weapon) {
this.weapon = weapon;
}
/**
* Accessor for location value
*
* @return location integer value
*/
public int getLocation() {
return location;
}
/**
* Mutator for location value
*
* @param location
* integer value representing location
*/
public void setLocation(int location) {
this.location = location;
}
/**
* Accessor for person value
*
* @return person integer value
*/
public int getPerson() {
return person;
}
/**
* Mutator for person value
*
* @param person
* integer value representing person
*/
public void setPerson(int person) {
this.person = person;
}
/**
* Equals method checks ALL instance variables are equal
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
Theory other = (Theory) obj;
return (this.weapon != other.weapon || this.person != other.person || this.location != other.location);
}
/**
* toString representing objects values
*
* @return formatted string of weapon, person, and location
*/
@Override
public String toString() {
return String.format("Theory is: Weapon = %s (%d), Person = %s (%d), Location = %s (%d)",
TheoryItem.getWeaponName(this.weapon), this.weapon, TheoryItem.getPersonName(this.person), this.person,
TheoryItem.getLocationName(this.location), this.location);
}
}