-
Notifications
You must be signed in to change notification settings - Fork 0
/
Course.java
273 lines (248 loc) · 6.89 KB
/
Course.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
import java.util.ArrayList;
import java.util.UUID;
/**
* A Course
* @authors: J TEA: Tessa Neal, Eve Blom, Anna Phan, and Jacqueline Askey
*/
public class Course {
private UUID id;
private Difficulty difficulty;
private String name;
private String description;
private String syllabus;
private UUID author;
private ArrayList<Module> modules = new ArrayList<Module>();
private Language language;
private ArrayList<Student> students = new ArrayList<Student>();
private double rating;
private ArrayList<Review> reviews = new ArrayList<Review>();
private ArrayList<Comment> comments = new ArrayList<Comment>();
/**
* Creates a Course
* @param author UUID of Author
* @param name name of Course
* @param description description of Course
* @param syllabus syllabus of Course
* @param difficulty difficulty of Course
* @param language language of Course
* @param modules modules of Course
*/
public Course(UUID author, String name, String description, String syllabus, Difficulty difficulty, Language language, ArrayList<Module> modules){
this.id = UUID.randomUUID();
this.author = author;
this.name = name;
this.description = description;
this.difficulty = difficulty;
this.language =language;
this.syllabus = syllabus;
this.modules = modules;
/*reviews = new ArrayList<>();
modules = new ArrayList<>();
comments = new ArrayList<>();*/
}
/**
* Creates a Course
* @param id UUID of the User
* @param difficulty difficulty of Course
* @param name name of Course
* @param description description of Course
* @param syllabus syllabus of Course
* @param author author of Course
* @param modules modules of Course
* @param language language of Course
* @param students students of Course
* @param rating rating of Course
* @param reviews reviews of Course
* @param comments comments of Course
*/
public Course(UUID id, Difficulty difficulty, String name, String description, String syllabus, UUID author, ArrayList<Module> modules, Language language, ArrayList<Student> students, double rating, ArrayList<Review> reviews, ArrayList<Comment> comments) {
this.id = id;
this.difficulty = difficulty;
this.name = name;
this.description = description;
this.syllabus = syllabus;
this.author = author;
this.modules = modules;
this.language = language;
this.students = students;
this.rating = rating;
this.reviews = reviews;
this.comments = comments;
}
/**
* Returns id
* @return a UUID id
*/
public UUID getId(){
return id;
}
/**
* Returns Title
* @return name of Course
*/
public String getTitle(){
return name;
}
/**
* Returns Author
* @return author
*/
public UUID getAuthor(){
return author;
}
/**
* Returns description
* @return description
*/
public String getDesciption(){
return description;
}
/**
* Returns difficulty
* @return difficulty
*/
public Difficulty getDifficulty(){
return difficulty;
}
/**
* Returns language
* @return language
*/
public Language getLanguage(){
return language;
}
/**
* Returns syllabus
* @return syllabus
*/
public String getSyllabus(){
return syllabus;
}
/**
* Adds a syllabus
* @param syllabus syllabus of course
*/
public void addSyllabus(String syllabus){
this.syllabus = syllabus;
}
/**
* Returns rating
* @return rating
*/
public double getRating(){
return rating;
}
/**
* Sets course rating
* @param rating int rating given
*/
public void setRating(int rating){
this.rating = rating;
}
/**
* Returns reviews
* @return An ArrayList of reviews
*/
public ArrayList<Review> getReview(){
return reviews;
}
/**
* Adds a review
* @param user review's user
* @param rating the rating
* @param comment the comment
*/
public void addReview(User user, double rating, String comment){
Review review = new Review(rating, comment, user.getId());
reviews.add(review);
}
/**
* Returns students
* @return An ArrayList of students
*/
public ArrayList<Student> getStudent(){
return students;
}
/**
* Returns how many modules in the Course
* @return number of modules
*/
public int getNumberOfModules(){
return modules.size();
}
/**
* Returns modules
* @return An ArrayList of modules
*/
public ArrayList<Module> getModule(){
return modules;
}
/**
* Returns a Module
* @param num the module number wanted
* @return a module
*/
public Module getModule(int num){
return modules.get(num);
}
/**
* Adds a Module
* @param title Module title
* @param lessons ArrayList of Lessons
*/
public void addModule(String title, ArrayList<Lesson> lessons){
Module module = new Module(title, lessons);
modules.add(module);
}
/**
* Returns comments
* @return An ArrayList of comments
*/
public ArrayList<Comment> getComment(){
return comments;
}
/**
* Returns details of the Course
* @return A string representation of a Course
*/
public String toString(){
String result = "Course ID: " + id + "\nDifficulty: " + difficulty + "\nName: " + name + "\nDescription: " + description + "\nSyllabus: " + syllabus + "\nAuthor ID: " + author;
result += "\nModules: \n";
for(Module module : modules) {
result += module;
System.out.println("Added module");
}
result += "\nLanguage: "+language+"\nActive Students:\n";
for(Student student : students) {
result += student;
}
result += "\nRating: "+rating;
result += "\nReviews:";
for(Review review : reviews) {
result += review;
}
result += "\nComments: ";
for(Comment comment : comments) {
result += comment;
}
return result;
}
/**
* Returns details of the Comment of Course
* @return A string representation of a Comment of Course
*/
public String commentsToString() {
String result = "";
for(Comment comment : comments) {
result += comment;
}
return result;
}
/**
* Adds a Comment to the comment ArrayList
* @param comment a comment
*/
public void addComment(Comment comment) {
comments.add(comment);
}
}