-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTARS.java
68 lines (64 loc) · 2.63 KB
/
STARS.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
import java.util.ArrayList;
public class STARS {
/**
* Check whether the index number has any vacancy left and the number of vacancy slots available
* @param indexNumber
*/
public static void checkVacancies(int indexNumber) {
//verification
if (UniDataBase.verifyClassIndex(indexNumber)==false) {
System.out.println("Course index "+indexNumber+" does not exist");
return;
}
ClassIndex classIndex = UniDataBase.findClassIndex(indexNumber);
int classVacancy= classIndex.getClassVacancy();
int totalClassSize= classVacancy + classIndex.getStudentList().size();
System.out.println("Course index "+indexNumber+" has "+classVacancy+" slot(s) left and maximum class size of "+totalClassSize+".");
}
/**
* prints out error message
*/
public static void showErrorMessage() {
System.out.println("Error! Please input again!");
}
/**
* prints out all courses including its name, code, number of AU, index number, as well as the lesson type
*/
public static void showAllCourses() {
String courseCode,lessonType,classDay,classVenue;
int indexNum,au,lessonsListSize,starttime,endtime;
Course course;
Lesson lesson;
System.out.println("Printing all courses... :");
System.out.println(String.format("%-13s%-4s%-11s%-6s%-5s%-9s%2s%2s","Course Code","AU","Index No.","Type","Day","Time"," ","Venue"));
System.out.println(String.format("%63s", "-").replace(' ', '-'));
ArrayList<Course> allCourses=UniDataBase.courses;
int allCoursesSize=allCourses.size();
for(int k=0;k<allCoursesSize;k++) {
course=allCourses.get(k);
ArrayList<ClassIndex> allIndexNumList=course.getIndexNumList();
int allIndexNumListSize = allIndexNumList.size();
for(int i=0;i<allIndexNumListSize;i++) {
courseCode = allIndexNumList.get(i).getCourseCode();
indexNum = allIndexNumList.get(i).getIndexNum();
course=UniDataBase.findCourseByCode(courseCode);
au=course.getAcadUnits();
lessonsListSize=allIndexNumList.get(i).getLessonsList().size();
for(int j=0;j<lessonsListSize;j++) {
lesson=allIndexNumList.get(i).getLessonsList().get(j);
lessonType=lesson.getLessonType();
classDay=lesson.getClassDay();
classVenue=lesson.getClassVenue();
starttime = lesson.getClassTiming()[0];
endtime=lesson.getClassTiming()[1];
if(j==0) {
System.out.println(String.format("%-13s%-4d%-11d%-6s%-5s%04d%-1s%04d%2s%2s", courseCode, au,indexNum,lessonType,classDay,starttime,"-",endtime," ",classVenue));
}
else {
System.out.println(String.format("%-13s%-4s%-11s%-6s%-5s%04d%-1s%04d%2s%2s", " ", " ", " ",lessonType,classDay,starttime,"-",endtime," ",classVenue));
}
}
}
}
}
}