blob: b2cd9de71ee5a6c535b542edc0b5afc0183e322c (
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="button is-success"` : 'class="button is-dark"';
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;
}
|