-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent.java
125 lines (100 loc) · 3.73 KB
/
Student.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
public class Student {
enum Gender {
FEMALE, MALE
};
enum Preference {
NEVER, NEUTRAL, ALOT
};
private String id;
private Gender gender;
private String email;
private Preference likesLoudMusic;
private Preference likesHavingPeopleOver;
private Preference sleepsDeeply;
private Preference likesTidySpace;
private Preference likesToSleepWithLightsOff;
private Preference howMuchPersonalSpace;
private Preference offCampusOrOn;
private boolean matched;
private boolean roomed;
public Student(String id, String gender, String email, int likesLoudMusic, int likesHavingPeopleOver,
int sleepsDeeply, int likesTidySpace, int likesToSleepWithLightsOff, int howMuchPersonalSpace,
int offCampusOrOn) {
this.id = id;
this.gender = (gender.equalsIgnoreCase("F")) ? Gender.FEMALE : Gender.MALE;
this.email = email;
this.likesLoudMusic = Preference.values()[likesLoudMusic];
this.likesHavingPeopleOver = Preference.values()[likesHavingPeopleOver];
this.sleepsDeeply = Preference.values()[sleepsDeeply];
this.likesTidySpace = Preference.values()[likesTidySpace];
this.likesToSleepWithLightsOff = Preference.values()[likesToSleepWithLightsOff];
this.howMuchPersonalSpace = Preference.values()[howMuchPersonalSpace];
this.offCampusOrOn = Preference.values()[offCampusOrOn];
matched = false;
roomed = false;
}
public String getId() {
return this.id;
}
public String getEmail() {
return this.email;
}
public Gender getGender() {
return this.gender;
}
public Preference getLikesLoudMusic() {
return this.likesLoudMusic;
}
public Preference getLikesHavingPeopleOver() {
return this.likesHavingPeopleOver;
}
public Preference getSleepsDeeply() {
return this.sleepsDeeply;
}
public Preference getLikesTidySpace() {
return this.likesTidySpace;
}
public Preference getLikesToSleepWithLightsOff() {
return this.likesToSleepWithLightsOff;
}
public Preference getHowMuchPersonalSpace() {
return this.howMuchPersonalSpace;
}
public Preference getOffCampusOrOn() {
return this.offCampusOrOn;
}
public void setMatched() {
this.matched = !matched;
}
public boolean isMatched() {
return matched;
}
public void setRoomed() {
this.roomed = !roomed;
}
public boolean hasRoom() {
return roomed;
}
public int[] getPreferenceArray() {
int[] preferenceArray = {
this.likesLoudMusic.ordinal(),
this.likesHavingPeopleOver.ordinal(),
this.sleepsDeeply.ordinal(),
this.likesTidySpace.ordinal(),
this.howMuchPersonalSpace.ordinal(),
this.offCampusOrOn.ordinal()
};
return preferenceArray;
}
public String toString() {
String generalInformation = String.format("id: %s\ngender: %s\nemail: %s\nis student matched: %s\n", this.id,
this.gender, this.email, this.matched);
String preferences1 = String.format(
"likes loud music: %s\nlikes having people over: %s\nsleeps deeply: %s\nlikes a tidy space: %s\n",
this.likesLoudMusic, this.likesHavingPeopleOver, this.sleepsDeeply, this.likesTidySpace);
String preferences2 = String.format(
"likes to sleep with lights off: %s\npersonal space: %s\nprefers to be off campus: %s",
this.likesToSleepWithLightsOff, this.howMuchPersonalSpace, this.offCampusOrOn);
return generalInformation + preferences1 + preferences2;
}
}