| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import { element } from "./element.js";
- class submission {
- #name;
- #description;
- #thumbnail;
- #elements;
- constructor(name) {
- if (typeof(name) !== "string") {
- throw "Name must be an string.";
- }
- this.#name = name;
- this.#description = "";
- this.#thumbnail = "";
- 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 thumbnail() {
- return this.#thumbnail;
- }
- set thumbnail(content) {
- if (typeof(content) !== "string") {
- throw "Thumbnail must be an string.";
- }
- this.#thumbnail = content;
- }
- get names() {
- return Object.keys(this.#elements);
- }
- get elements() {
- return Object.values(this.#elements);
- }
- add(item) {
- if (!(item instanceof element)) {
- throw "Trying to add something which is not an element.";
- }
- if (item.name in this.#elements) {
- throw "Trying to add element which already exists in submission.";
- }
- this.#elements[item.name] = item;
- }
- get(name) {
- if (typeof(name) !== "string") {
- throw "Name must be an string.";
- }
- if (!(name in this.#elements)) {
- throw "Trying to get element which not exists.";
- }
- return this.#elements[name];
- }
- clean() {
- this.#elements = {};
- }
- }
- export { submission };
|