This repository has been archived by the owner on Jun 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tutorial.java
90 lines (78 loc) · 1.96 KB
/
Tutorial.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
import java.io.Serializable;
/**
* Represents a tutorial session of a course.
* A course can have multiple tutorial sessions.
* A tutorial session can only belong to one course.
* @author Group3
* @version 1.0
*/
public class Tutorial implements Session, Serializable {
/**
* Size of this tutorial.
*/
private int size;
/**
* Id of this tutorial.
*/
private int id;
/**
* Number of vacancies of this tutorial.
*/
private int vacancy;
/**
* <code>Tutorial</code> constructor
* Creates a new tutorial session with given id and size.
* Sets initial vacancies of this tutorial equal to size of this tutorial.
* @param id id of this tutorial
* @param size size of this tutorial
*/
public Tutorial(int id, int size){
this.size = size;
this.id = id;
this.vacancy = size;
}
/**
* Gets the id of this tutorial.
* @return the id of this tutorial
*/
public int getID(){
return id;
}
/**
* Gets the number of vacancies of this tutorial.
* @return the number of vacancies of this tutorial
*/
public int getVacancy(){
return vacancy;
}
/**
* Gets tht size of this tutorial.
* @return the size of this tutorial
*/
public int getSize(){
return size;
}
/**
* Checks if this tutorial session is full or not by checking this tutorial's vacancy.
* @return a boolean value
* true if this tutorial is full
* false if this tutorial has vacancy
*/
public boolean isFull() {
return vacancy == 0;
}
/**
* Reduces the number of vacancies by one when a student registers this tutorial session.
*/
public void registered(){
vacancy--;
}
/**
* Checks if this tutorial session is empty or not,
* by checking whether the size equals to vacancy or not.
* @return a boolean value
* true if this tutorial session if empty (no student registers this tutorial session)
* false if there are students register this tutorial session
*/
public boolean isEmpty(){return size == vacancy;}
}