aboutsummaryrefslogtreecommitdiffstats
path: root/public/projects/js-small-apps/budget-app/lib/class-category.js
blob: 7b2f1b23fe4e96a77bec504def22cd40b03a2c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
 * Category class.
 *
 * Create a new category with id, name and attachments.
 */
class Category {
  #id = 0;
  #name = "";
  #attachments = [];

  constructor(id, name) {
    this.#id = Number(id);
    this.#name = name;
  }

  set name(name) {
    this.#name = name;
  }

  get name() {
    return this.#name;
  }

  get id() {
    return this.#id;
  }

  set attachments(attachment) {
    this.#attachments.push(Number(attachment));
  }

  get attachments() {
    return this.#attachments;
  }
}

export default Category;