-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.java
116 lines (112 loc) · 2.96 KB
/
Module.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.util.ArrayList;
/**
* This is a module that holds lessons
* @authors: J TEA: Tessa Neal, Eve Blom, Anna Phan, and Jacqueline Askey
*/
public class Module {
private ArrayList<Lesson> lessons = new ArrayList<Lesson>();
private ArrayList<Comment> comments = new ArrayList<Comment>();
private String title;
/**
* Creates a new module
* @param title module title
* @param lessons lessons in module
*/
public Module(String title, ArrayList<Lesson> lessons) {
this.title = title;
setLesson(lessons);
}
/**
* Creats a new module
* @param name module title
* @param lessons
* @param comments
*/
public Module(String name, ArrayList<Lesson> lessons, ArrayList<Comment> comments) {
title = name;
this.lessons.addAll(lessons);
this.comments.addAll(comments);
}
/**
* gets the title of th e module
* @return module title
*/
public String getTitle() {
return title;
}
/**
* gets the lessons in the module
* @return module lessons
*/
public ArrayList<Lesson> getLesson() {
return lessons;
}
/**
* set the lessons to the module
* @param lessons lessons
*/
public void setLesson(ArrayList<Lesson> lessons) {
this.lessons.addAll(lessons);
}
/**
* get lesson accordinf to it's place in the arraylist
* @param index lesson position
* @return lesson in that position
*/
public Lesson getLesson(int index) {
return lessons.get(index);
}
/**
* get number of lessons in module
* @return number of lessons
*/
public int getNumberOfLessons() {
return lessons.size();
}
/**
* adds a lesson to the module
* @param content lesson content
* @param title lesson title
* @param quiz lesson quiz
*/
public void addLesson(String content, String title, Quiz quiz) {
Lesson lesson = new Lesson(content, title, quiz);
lessons.add(lesson);
}
/**
* get the comments in module
* @return comments
*/
public ArrayList<Comment> getComment() {
return comments;
}
/**
* Creates a string representation of the lesson
*/
public String toString() {
String result = "Title: " + title + "\n";
result += "Lessons:\n";
for (Lesson lesson : lessons) {
result += lesson;
System.out.println("Added lesson");
}
result += "Comments: \n";
for (Comment comment : comments) {
result += comment;
}
result += "\n";
return result;
}
/**
* Lesson infomation
* @return lesson
*/
public String fileInfo() {
String result = "Title: " + title + "\n";
result += "Lessons:\n";
for (int i = 0; i < lessons.size(); i++) {
result += lessons.get(i).miniToString();
}
return result;
}
}