multiple schedule suppport kinda
This commit is contained in:
@@ -45,6 +45,9 @@ export class Course {
|
||||
courseName: string;
|
||||
/** The unique identifier for which department that a course belongs to, i.e. CS, MAL, etc. */
|
||||
department: string;
|
||||
|
||||
/** The number of credits that a course is worth */
|
||||
creditHours: number;
|
||||
/** Is the course open, closed, waitlisted, or cancelled? */
|
||||
status: Status;
|
||||
/** all the people that are teaching this course, and some metadata about their names */
|
||||
|
||||
35
src/shared/types/UserSchedule.ts
Normal file
35
src/shared/types/UserSchedule.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Serialized } from 'chrome-extension-toolkit';
|
||||
import { Course } from './Course';
|
||||
|
||||
/**
|
||||
* Represents a user's schedule that is stored in the extension
|
||||
*/
|
||||
export class UserSchedule {
|
||||
courses: Course[];
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
constructor(schedule: Serialized<UserSchedule>) {
|
||||
this.courses = schedule.courses.map(c => new Course(c));
|
||||
this.id = schedule.id;
|
||||
this.name = schedule.name;
|
||||
}
|
||||
|
||||
containsCourse(course: Course): boolean {
|
||||
return this.courses.some(c => c.uniqueId === course.uniqueId);
|
||||
}
|
||||
|
||||
getCreditHours(): number {
|
||||
return this.courses.reduce((acc, course) => acc + course.creditHours, 0);
|
||||
}
|
||||
|
||||
addCourse(course: Course): void {
|
||||
if (!this.containsCourse(course)) {
|
||||
this.courses.push(course);
|
||||
}
|
||||
}
|
||||
|
||||
removeCourse(course: Course): void {
|
||||
this.courses = this.courses.filter(c => c.uniqueId !== course.uniqueId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user