-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
193 lines (165 loc) · 4.1 KB
/
Copy pathPerson.java
File metadata and controls
193 lines (165 loc) · 4.1 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/**
* Person represents a person, or something like one, in this logic puzzle.
*
* @author ace
* @version 11 April 2010
*/
public class Person
{
// instance variables - replace the example below with your own
private boolean isMad;
private boolean isAMarchHare;
private boolean isAPolitician;
private boolean isAManager;
private boolean isASecretary;
private boolean isARabbit;
private boolean isWhite;
private boolean isWonderous;
private boolean isLate;
/**
* Constructor for objects of class Person
*/
public Person(){
isMad = false;
isAMarchHare = false;
isAPolitician = false;
isAManager = false;
isASecretary = false;
isARabbit = false;
isWhite = false;
isWonderous = false;
isLate = false;
}
public void setIsMad(){
isMad = true;
madCheck();
}
public boolean getIsMad(){
return isMad;
}
public void setIsAMarchHare(){
isAMarchHare = true;
hareCheck();
}
public boolean getIsAMarchHare(){
return isAMarchHare;
}
public void setIsAPolitician(){
isAPolitician = true;
politicianCheck();
}
public boolean getIsAPolitician(){
return isAPolitician;
}
public void setIsAManager(){
isAManager = true;
managerCheck();
}
public boolean getIsAManager(){
return isAManager;
}
public void setIsASecretary(){
isASecretary = true;
secretaryCheck();
}
public boolean getIsASecretary(){
return isASecretary;
}
public void setIsARabbit(){
isARabbit = true;
}
public boolean getIsARabbit(){
return isARabbit;
}
public void setIsWhite(){
isWhite = true;
whiteCheck();
}
public boolean getIsWhite(){
return isWhite;
}
public void setIsWonderous(){
isWonderous = true;
wonderousCheck();
}
public boolean getIsWonderous(){
return isWonderous;
}
public void setIsLate(){
isLate = true;
lateCheck();
}
public boolean getIsLate(){
return isLate;
}
private void madCheck(){
if(isAPolitician && isLate){
isMad = false;
} else {
isAManager = false; isAPolitician = false;
isLate = false; isWhite = false;
}
}
private void hareCheck(){
if(isMad){
} else {
if(isAPolitician && isLate){
isAMarchHare = false;
} else {
setIsMad();
}
}
}
private void politicianCheck(){
if(isMad && (isAMarchHare || isASecretary || !isLate)){
isAPolitician = false;
} else {
isAMarchHare = false; isMad = false;
isASecretary = false;
}
}
private void managerCheck(){
if(!(isAPolitician || isLate) && isMad){
isAManager = false;
} else {
setIsAPolitician();
}
}
private void secretaryCheck(){
if(!isMad && (isAPolitician || isLate)){
isASecretary = false;
} else {
setIsMad();
}
}
private void whiteCheck(){
if(isARabbit){
if(isMad && (isAMarchHare || isASecretary)){
isWhite = false;
} else {
isLate = true;
setIsWonderous();
}
}
}
private void wonderousCheck(){
if(isLate){
isWhite = true;
setIsARabbit();
} else {
isARabbit = false;
}
}
private void lateCheck(){
if(isMad && (isAMarchHare || isASecretary)){
isLate = false;
} else {
isMad = false; isAMarchHare = false;
isASecretary = false;
if(isWonderous){
isWhite = true;
setIsARabbit();
}
}
}
}