forked from CSnakeEyes/RegistrationSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
62 lines (59 loc) · 1.54 KB
/
Course.java
File metadata and controls
62 lines (59 loc) · 1.54 KB
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
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
public class Course {
public String department;
public int CRN;
public String name;
public Professor teacher;
public Set<Student> students;
public Set<Student> waitingList;
public int waitingListCap;
public int activeWaitingList;
public int activeStudents;
public int studentCap;
public int hours;
public boolean passed;
public Course(String name, String department, Professor teacher, int waitingListCap, int studentCap, int hours, Set<Course> allCourses){
this.name = name;
this.department = department;
this.teacher = teacher;
this.waitingListCap = waitingListCap;
this.studentCap = studentCap;
this.hours = hours;
Random rand = new Random();
boolean uniqueLoop = true;
int tries = 0;
int tempCRN =-1;
while(uniqueLoop && tries < 100){
tempCRN = rand.nextInt((9999 - 0) + 1) + 0;
boolean match = false;
tries++;
Iterator<Course> it = allCourses.iterator();
while(it.hasNext()){
Course current = it.next();
if(current.name == name){
CRN = -1;
return;
}
if(current.CRN == CRN)
match = true;
if(match)
uniqueLoop = true;
else
uniqueLoop = false;
}
}
CRN = tempCRN;
}
public static Course findCourse(Set<Course> allCourses, String inputCourse){
Iterator<Course> it = allCourses.iterator();
while(it.hasNext()){
Course current = it.next();
if(current.name == inputCourse){
return current;
}
}
return null;
}
}