aboutsummaryrefslogtreecommitdiffstats
path: root/public/projects/js-small-apps/budget-app/lib/class-user.js
blob: e0e137b20bd8614b901151c38333ae7848181c7c (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import Budget from "./class-budget.js";

class User {
  #id = 0;
  #username = "Anonymous";
  #firstName = "John";
  #lastName = "Doe";
  #role = "admin";
  #locale = "en-US";
  #accountCreation = new Date();
  #budget = 0;

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

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

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

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

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

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

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

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

  set role(string) {
    this.#role = string;
  }

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

  set locale(code) {
    this.#locale = code;
  }

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

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

  set budget(number) {
    this.#budget = new Budget(number);
  }

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

  name() {
    return `${this.#firstName} ${this.#lastName}`;
  }
}

export default User;