aboutsummaryrefslogtreecommitdiff
path: root/court.mjs
blob: 31f277f4b5481053f48244fdd3aa497df997ad99 (plain) (blame)
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
export class Court {
    constructor(id) {
        this.id = id;
        this.name = "Court " + (id + 1);
        this.status = true;
    }
    toggle() {
        this.status = !this.status;
        this.print();
    }
    print() {
        let status = this.status ? "active" : "inactive";
        console.log(this.name + " is currently " + status);
    }
    render() {
        let type = this.status ? "" : 'class="outline secondary"';
        return `<button id=${"court_" + this.id} ${type}>${this.name}</button>`;
    }
}

export function generateCourts() {
    let courts = [];
    const totalCourts = 12;
    for (let i = 0; i < totalCourts; i++) {
        courts.push(new Court(i));
    }
    return courts;
}