Skip to content

Instantly share code, notes, and snippets.

@rawnly
Created May 18, 2022 11:16
Show Gist options
  • Save rawnly/ffa7d6b7c4914b481f15d4cab987be27 to your computer and use it in GitHub Desktop.
Save rawnly/ffa7d6b7c4914b481f15d4cab987be27 to your computer and use it in GitHub Desktop.
export class Numbers {
#data: number[];
#max = 0;
addNumber(num: number) {
this.#max = Math.max(num, this.#max);
this.#data.push(num);
}
getAll(): number[] {
return this.#data;
}
deleteLast() {
this.#data = this.#data.slice(0, this.#data.length - 2);
}
getMax(): number {
return this.#max;
}
}
interface Numbers {
addNumber(num: number): void;
getAll(): number[];
deleteLast(): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment