-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerritory.java
More file actions
95 lines (95 loc) · 2.95 KB
/
Copy pathTerritory.java
File metadata and controls
95 lines (95 loc) · 2.95 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
package lab4;
import java.util.Objects;
import java.util.ArrayList;
public class Territory implements Describable{
private String name;
private Area type;
private Sky sky;
private Twilight twilight;
private ArrayList<WaterObject> waterObjects = new ArrayList<>();
private Creature hero1;
private Creature hero2;
public Territory () {
name = "Безымянный";
type = Area.CITY;
sky = new Sky(type, name);
}
public Territory (Area type, String name, Creature hero1, Creature hero2) {
this.type = type;
this.name = name;
this.hero1 = hero1;
this.hero2 = hero2;
sky = new Sky(type, name);
twilight = new Twilight(type, name);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String getInformation() {
return type.getArea() + " " + name;
}
public void addWaterObject (TypeOfWaterObject type) {
WaterObject object = new WaterObject(type, this.type, name);
waterObjects.add(object);
}
public WaterObject getWaterObject (int index) {
WaterObject object;
if (index < waterObjects.size()) {
object = waterObjects.get(index);
} else {
object = new WaterObject(type, name);
}
return object;
}
public Sky getSky() {
return sky;
}
public Twilight getTwilight() {
return twilight;
}
public void describeTerritory(Time time) {
System.out.println("На территории " + type.getArea() + " " + name + " " + time.getTime() + ".");
}
public void describeGlow() {
if (sky.getGlow()) {
if ((name == "Стокгольм") && (type == Area.CITY)) {
System.out.println("На территории " + type.getArea() + " " + name + " " + sky.showGlow() + ".");
} else {
System.out.println("На территории " + type.getArea() + " " + name + " " + sky.showGlow() + ".");
}
} else {
System.out.println("На территории " + type.getArea() + " " + name + " " + sky.showGlow() + ".");
}
}
public void describeTwilight() {
if (twilight.getStartTwilight()) {
if ((name == "Стокгольм") && (type == Area.CITY)) {
System.out.println("На территории " + type.getArea() + " " + name + " " + twilight.showTwilight() + ".");
} else {
System.out.println("На территории " + type.getArea() + " " + name + " " + twilight.showTwilight() + ".");
}
} else {
System.out.println("На территории " + type.getArea() + " " + name + " " + twilight.showTwilight() + ".");
}
}
public int hashCode() {
int r = Objects.hashCode(getInformation());
return r;
}
public boolean equals(Object territory1) {
if (territory1 == this) {
return true;
}
if (territory1 == null || getClass() != territory1.getClass()) {
return false;
}
Territory territory2 = (Territory) territory1;
return getInformation() == territory2.getInformation();
}
public String toString() {
return getInformation();
}
}