Skip to content

Instantly share code, notes, and snippets.

@ragmha
Created November 26, 2018 13:35
Show Gist options
  • Select an option

  • Save ragmha/1a413c1cf55a6d4354960d102ae9c0b5 to your computer and use it in GitHub Desktop.

Select an option

Save ragmha/1a413c1cf55a6d4354960d102ae9c0b5 to your computer and use it in GitHub Desktop.
abstract class Sizes {
constructor(public sizes: string[]) {}
set availableSizes(sizes: string[]) {
this.sizes = sizes;
}
get availableSizes() {
return this.sizes;
}
}
class Pizza extends Sizes {
public toppings: string[] = [];
constructor(readonly name: string, public sizes: string[]) {
super(sizes);
}
public addTopping(topping: string) {
this.toppings.push(topping);
}
}
const pizza = new Pizza("Peppuriiini", ["small", "medium"]);
console.log(pizza.availableSizes);
pizza.addTopping("Pururuur");
pizza.addTopping("Tomaaato");
console.log(pizza.toppings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment