Created
November 26, 2018 13:31
-
-
Save ragmha/acde38da24abdeb3975c17a5d01d94f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 addToping(topping: string) { | |
this.toppings.push(topping); | |
} | |
} | |
const pizza = new Pizza("Pepperoni", ["small", "medium"]); | |
console.log(pizza.availableSizes); | |
pizza.addToping("Pepper"); | |
console.log(pizza.toppings); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment