import type { Student } from "./student-common.ts"; /** * Class to represent a Group of Students. */ class Group { name: string; students: Array = []; constructor(name: string, students?: Array) { this.name = name; if (typeof students !== "undefined") { this.students = students; } } setStudents(students: Array) { this.students = students; } addStudent(student: Student) { this.students.push(student); } async getStudents() { return this.students; } } const groups = new Map(); function buildGroups(students: Array) { for (const student of students) { let group = groups.get(student.group); if (!group) { group = new Group(student.group); groups.set(student.group, group); } group.addStudent(student); } } export { Group, buildGroups, groups as _groups };