-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
59 lines (50 loc) · 1.58 KB
/
Copy pathCourse.java
File metadata and controls
59 lines (50 loc) · 1.58 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
import java.io.Serializable;
import java.util.ArrayList;
/**
* Project 4 - Course
* <p>
* The Course class implements Serializable and has an array list of quizzes where you can get a quiz, add a quiz, or delete a quiz.
* @author Aarohi Panzade, Abel Zazjon, Aditi Barla, and Yaseen Shady 039
*
* @version 11/14/2021
*/
public class Course implements Serializable {
// Constructs a newly allocated Course object with the field values specified by the input parameters.
public Course(String name) {
this.name = name;
this.quizzes = new ArrayList<>();
}
// initializes the fields
private ArrayList<Quiz> quizzes;
private String name;
// returns the name of the course
public String getName() {
return name;
}
// returns the array list of the quizzes
public ArrayList<Quiz> getQuizzes() {
return quizzes;
}
//returns a quiz based on the name of the quiz
public Quiz getQuiz(String quizName) {
//for each loop with a quiz object to check if the name of the quiz the user typed in is equal to the one that the teacher creates
for (Quiz quiz: quizzes) {
if(quiz.getQuizName().equals(quizName)) {
return quiz;
}
}
return null;
}
// adds a quiz to the list of the quizzes
public void addQuiz(Quiz q) {
// checks if a quiz is null
if (q == null) {
return;
}
quizzes.add(q);
}
// deletes a quiz from the list of quizzes
public void deleteQuiz(Quiz q) {
quizzes.remove(q);
}
}