forked from ian-lopez/Roommate-Compatability
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
67 lines (56 loc) · 1.02 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
public class Student
{
protected String name;
protected char gender;
protected Date birthdate;
protected Preference pref;
protected boolean match;
public Student(String name, char gender, Date birthdate, Preference pref)
{
this.name = name;
this.gender = gender;
this.birthdate = birthdate;
this.pref = pref;
match = false;
}
public String getName()
{
return name;
}
public char getGender()
{
return gender;
}
public Date getDate()
{
return birthdate;
}
public Preference getPref()
{
return pref;
}
public boolean getMatch()
{
return match;
}
public boolean setMatch()
{
if(match) {
match = false;
return false;
}
match = true;
return true;
}
public int compare(Student st)
{
int score = 0;
if(st.getGender() != this.getGender())
return score;
else
{
score += Math.abs(40 - pref.compare(st.pref)) + Math.abs(60 - birthdate.compare(st.birthdate));
return score;
}
}
}