-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.java
90 lines (67 loc) · 1.78 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
/** Student is a class that has some methods and implements Comparable<T>
*
* @author egecans
*
*/
public class Student implements Comparable<Student>{
private String name;
private int id, duration;
private double rating;
/** Constructor of Student class which has a signature with 4 parameters.
*
* @param id id of Student
* @param name Student's name
* @param duration a duration that student will study
* @param rating a minimum rate of house that requires that student could stay.
*/
public Student (int id, String name, int duration, double rating) {
this.name=name;
this.id=id;
this.duration=duration;
this.rating=rating;
}
/** that method checks whether student could stay a house (that has a parameter rate) or not.
*
* @param rate rate of the house checked
* @return boolean
*/
public Boolean rateChecker(double rate){
if (rate>=this.rating)
return true;
return false;
}
/** after 1 semester passed that method decrease a duration by 1.
*
*/
public void oneSemesterPassed() {
this.duration = duration-1;
}
/** that method checks the semester whether it's 0 or not.
* if it's zero that returns false and in main class it is useful for some operations.
* @return boolean
*/
public Boolean semesterChecker() {
if (this.duration==0) {
return false;
}
return true;
}
/** the method compares Students with respect to their ids.
*
*/
public int compareTo(Student other) {
return this.id-other.getId();
}
public int getDuration() {
return duration;
}
public int getId() {
return id;
}
public double getRating() {
return rating;
}
public String getName() {
return name;
}
}