OOP2

Added a fifth challenge, which is basically a rewrite of challenge 1, 2, and 3. Will be completed when the tumors from Java have been removed.

Author
Vngngdn
Date
Nov. 2, 2016, 7:22 p.m.
Hash
fb0e73da027f76aabc6aaffd74b94aff5f576f50
Parent
8cae9e7880bf439dbdf2cb88af4943882d72e4b4
Modified files
Challenge 5/Course.java
Challenge 5/Data.java
Challenge 5/MandatoryCourse.java
Challenge 5/Study.java
Challenge 5/StudyPlan.java

Challenge 5/Course.java

59 additions and 0 deletions.

View changes Hide changes
+
1
+
2
public class Course {
+
3
+
4
	private String name;
+
5
	private int semester;
+
6
	private int studyPoints;
+
7
	private int ID;
+
8
	private Set<Course> requiredCourses;
+
9
+
10
	public Course(String name, int semester, int studyPoints, int ID, Set<Course> requiredCourses) {
+
11
		this.name = name;
+
12
		this.semester = semester;
+
13
		this.studyPoints = studyPoints;
+
14
		this.ID = ID;
+
15
		this.requiredCourses = requiredCourses;
+
16
	}
+
17
+
18
	public void setName(String name) {
+
19
		this.name = name;
+
20
	}
+
21
+
22
	public String getName() {
+
23
		return name;
+
24
	}
+
25
+
26
	public void setSemester(int semester) {
+
27
		this.semester = semester;
+
28
	}
+
29
+
30
	public int getSemester() {
+
31
		return semester;
+
32
	}
+
33
+
34
	public void setStudyPoints(int studyPoints) {
+
35
		this.studyPoints = studyPoints;
+
36
	}
+
37
+
38
	public int getStudyPoints() {
+
39
		return studyPoints;
+
40
	}
+
41
+
42
	public void setID(int ID) {
+
43
		this.ID = ID;
+
44
	}
+
45
+
46
	public int getID() {
+
47
		return ID;
+
48
	}
+
49
+
50
	public void setRequiredCourses(Set<Course> requiredCourses) {
+
51
		this.requiredCourses = requiredCourses;
+
52
	}
+
53
+
54
	public Set<Course> getRequiredCourses() {
+
55
		return requiredCourses;
+
56
	}
+
57
+
58
}
+
59

Challenge 5/Data.java

46 additions and 0 deletions.

View changes Hide changes
+
1
import java.util.HashSet;
+
2
+
3
public class Data {
+
4
	public static Set<Course> createCourses() {
+
5
		// TODO
+
6
	}
+
7
	
+
8
	/**
+
9
	 * Creates sample studies that can be used for testing purposes.
+
10
	 * This method will create a sample that represents all the studies from the
+
11
	 * Science faculty at UHasselt. These can then be applied in the program as
+
12
	 * sample data.
+
13
	 * @return A set of 5 (undergraduate) studies.
+
14
	 */
+
15
	public static Set<Study> createStudies() {
+
16
		// Biology:
+
17
		// Chemistry:
+
18
		// Physics:
+
19
		// Informatics:
+
20
		// Mathematics:
+
21
		// TODO
+
22
	}
+
23
+
24
	public static Set<Course> deriveCoursesFromStudies(Set<Study> studies) {
+
25
		// TODO
+
26
	}
+
27
+
28
	/**
+
29
	 * Creates all courses specific to the Biology study.
+
30
	 * @return A set containing all courses specific to the Biology study.
+
31
	 */
+
32
	private static Set<Course> createBiologyCourses() {
+
33
		Set<Course> courses = new HashSet();
+
34
		courses.add(new MandatoryCourse(
+
35
					"Inleiding Algoritmen en Programmeren", 1, 5, 3326, null, 1));
+
36
		courses.add(new MandatoryCourse(
+
37
					"Computer- en communicatiesystemen", 1, 5, 2191, null, 1));
+
38
+
39
+
40
+
41
+
42
+
43
+
44
	}
+
45
}
+
46

Challenge 5/MandatoryCourse.java

20 additions and 0 deletions.

View changes Hide changes
+
1
+
2
public class MandatoryCourse extends Course {
+
3
+
4
	private int year;
+
5
+
6
	public MandatoryCourse(String name, int semester, int studyPoints, int ID, Set<Course> requiredCourses, int year) {
+
7
		super(name, semester, studyPoints, ID, requiredCourses);
+
8
		this.year = year;
+
9
	}
+
10
+
11
	public void setYear(int year) {
+
12
		this.year = year;
+
13
	}
+
14
+
15
	public int getYear() {
+
16
		return year;
+
17
	}
+
18
+
19
}
+
20

Challenge 5/Study.java

49 additions and 0 deletions.

View changes Hide changes
+
1
+
2
public class Study {
+
3
+
4
	private String name;
+
5
	private int duration;
+
6
	private int studyPoints;
+
7
	private Set<Course> courses;
+
8
+
9
	public Study(String name, int duration, int studyPoints, Set<Course> courses) {
+
10
		this.name = name;
+
11
		this.duration = duration;
+
12
		this.studyPoints = studyPoints;
+
13
		this.courses = courses;
+
14
	}
+
15
+
16
	public void setName(String name) {
+
17
		this.name = name;
+
18
	}
+
19
+
20
	public String getName() {
+
21
		return name;
+
22
	}
+
23
+
24
	public void setDuration(int duration) {
+
25
		this.duration = duration;
+
26
	}
+
27
+
28
	public int getDuration() {
+
29
		return duration;
+
30
	}
+
31
+
32
	public void setStudyPoints(int studyPoints) {
+
33
		this.studyPoints = studyPoints;
+
34
	}
+
35
+
36
	public int getStudyPoints() {
+
37
		return studyPoints;
+
38
	}
+
39
+
40
	public void setCourses(Set<Course> courses) {
+
41
		this.courses = courses;
+
42
	}
+
43
+
44
	public Set<Course> getCourses() {
+
45
		return courses;
+
46
	}
+
47
+
48
}
+
49

Challenge 5/StudyPlan.java

39 additions and 0 deletions.

View changes Hide changes
+
1
+
2
public class StudyPlan {
+
3
+
4
	private Study study;
+
5
	private Set<Course> pickedCourses;
+
6
	private Set<Courses> passedCourses;
+
7
+
8
	public StudyPlan(Study study, Set<Course> pickedCourses, Set<Courses> passedCourses) {
+
9
		this.study = study;
+
10
		this.pickedCourses = pickedCourses;
+
11
		this.passedCourses = passedCourses;
+
12
	}
+
13
+
14
	public void setStudy(Study study) {
+
15
		this.study = study;
+
16
	}
+
17
+
18
	public Study getStudy() {
+
19
		return study;
+
20
	}
+
21
+
22
	public void setPickedCourses(Set<Course> pickedCourses) {
+
23
		this.pickedCourses = pickedCourses;
+
24
	}
+
25
+
26
	public Set<Course> getPickedCourses() {
+
27
		return pickedCourses;
+
28
	}
+
29
+
30
	public void setPassedCourses(Set<Courses> passedCourses) {
+
31
		this.passedCourses = passedCourses;
+
32
	}
+
33
+
34
	public Set<Courses> getPassedCourses() {
+
35
		return passedCourses;
+
36
	}
+
37
+
38
}
+
39