-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstructions.java
More file actions
64 lines (64 loc) · 2.06 KB
/
Copy pathInstructions.java
File metadata and controls
64 lines (64 loc) · 2.06 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
package lab4;
import java.util.Objects;
abstract class Instructions {
private TypeOfAction action;
private String object;
private Creature creature;
private String condition;
public Instructions(TypeOfAction action, String object, Creature creature, String condition) {
this.action = action;
this.object = object;
this.creature = creature;
this.condition = condition;
}
public TypeOfAction getAction() {
return action;
}
public String getObject() {
return object;
}
public Creature getCreature() {
return creature;
}
public String getCondition() {
return condition;
}
public int hashCode() {
int r = Objects.hashCode(getInformation());
return r;
}
public boolean equals(Object instruction1) {
if (instruction1 == this) {
return true;
}
if (instruction1 == null || getClass() != instruction1.getClass()) {
return false;
}
Instructions instruction2 = (Instructions) instruction1;
return getInformation() == instruction2.getInformation();
}
public String toString() {
return getInformation();
}
abstract String getInformation();
public static class Prohibition extends Instructions {
public Prohibition(TypeOfAction action, String object, Creature creature, String condition) {
super(action, object, creature, condition);
}
public String getInformation() {
String s;
s = "запрет на действие \"" + getAction().getType() + "\", существо - " + getCreature().getName() + ", объект - " + getObject() + ", условие: " + getCondition();
return s;
}
}
public static class Permission extends Instructions {
public Permission(TypeOfAction action, String object, Creature creature, String condition) {
super(action, object, creature, condition);
}
public String getInformation() {
String s;
s = "разрешение на действие \"" + getAction().getType() + "\", существо - " + getCreature().getName() + ", объект - " + getObject() + ", условие: " + getCondition();
return s;
}
}
}