| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { submission } from "./submission.js";
- class project {
- #name;
- #description;
- #submissions;
- constructor(name) {
- this.#name = name;
- this.#description = "";
- this.clean();
- }
- get name() {
- return this.#name;
- }
- get description() {
- return this.#description;
- }
- set description(content) {
- if (typeof(content) !== "string") {
- throw "Description must be an string.";
- }
- this.#description = content;
- }
- get names() {
- return Object.keys(this.#submissions);
- }
- get submissions() {
- return Object.values(this.#submissions);
- }
- get first_submission() {
- if (this.submissions.length < 1) {
- throw "In project must be minimum one submission to get first.";
- }
- return this.submissions[0];
- }
- get(name) {
- if (typeof(name) !== "string") {
- throw "Name of submission must be an string.";
- }
- return this.#submissions[name];
- }
- add(content) {
- if (!(content instanceof submission)) {
- throw "New submission must be instance of submission class.";
- }
- if (content.name in this.#submissions) {
- throw "Trying to add submission which already exists.";
- }
- this.#submissions[content.name] = content;
- }
- clean() {
- this.#submissions = {};
- }
- }
- export { project };
|