| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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(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 };
|