-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.java
More file actions
119 lines (109 loc) · 3.84 KB
/
Human.java
File metadata and controls
119 lines (109 loc) · 3.84 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
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Human extends aCreature implements Comparable<Human>{
enum BootsTypeOn {
None,
Sneakers,
Sandals;
}
enum StandsOn {
Parket,
Asphalt,
Concrete;
}
enum State {
Angry,
OutOfBreath,
Relaxed
}
private String name;
private Date appeared = new java.util.Date();
private int weight;
private boolean flyingType;
private Gender gender;
private BootsTypeOn boots;
private StandsOn standOn;
private State state = State.Relaxed;
Human (String name, Gender gender, boolean flyingType, BootsTypeOn boots, StandsOn floor, int weight){
this.name = name;
this.gender = gender;
this.flyingType = flyingType;
this.boots = boots;
standOn = floor;
/*try {
this.birth = dateFormat.parse(birth);
}catch (ParseException e) {
e.printStackTrace();
}*/
this.weight = weight;
System.out.println("Создан персонаж с именем " + name + " и полом " + gender);
}
Human (String name, Gender gender, boolean flyingType, BootsTypeOn boots, StandsOn floor){
this.name = name;
this.gender = gender;
this.flyingType = flyingType;
this.boots = boots;
standOn = floor;
System.out.println("Создан персонаж с именем " + name + " и полом " + gender);
}
Human (String name, Gender gender, boolean flyingType, BootsTypeOn boots){
this.name = name;
this.gender = gender;
this.flyingType = flyingType;
this.boots = boots;
System.out.println("Создан персонаж с именем " + name + " и полом " + gender);
}
Human (String name, Gender gender, boolean flyingType){
this.name = name;
this.gender = gender;
this.flyingType = flyingType;
System.out.println("Создан персонаж с именем " + name + " и полом " + gender);
}
Human (String name, boolean flyingType){
this.name = name;
this.gender = null;
this.flyingType = flyingType;
System.out.println("Создан персонаж с именем " + name + " и полом " + gender);
}
private int countNotGiveUp = 0;
public int getCountNotGiveUp() {
return countNotGiveUp;
}
public void setCountNotGiveUp(int countNotGiveUp) {
this.countNotGiveUp = countNotGiveUp;
}
public void getShoes(){
if (this.boots == BootsTypeOn.None)
System.out.println(name + " стоит босиком на " + standOn);
}
public Gender getGender() throws NoGenderException{
if (gender == null){
throw new NoGenderException();
}
else {
return gender;
}
}
public String getName(){
return name;
}
public boolean getFlyingType(){
return flyingType;
}
public void setState(State state) {
this.state = state;
System.out.println("Состояние персонажа " + name + " изменен на " + state);
}
@Override
public String toString(){
String info = "Имя: " + this.name + " Пол: " + this.gender + " Возможность летать: " + this.flyingType + " Ботинки: " + this.boots + " Локация: " + this.standOn + " Дата появления: " + this.appeared;
return info;
}
public void setDate(){
this.appeared = new java.util.Date();
}
public int compareTo(Human h){
return name.compareTo(h.getName());
}
}