Created
November 26, 2018 13:41
-
-
Save ragmha/32d103b3f85b26d4e142973f4d3e19b7 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
abstract class Sizes { | |
constructor(protected 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, sizes: string[]) { | |
super(sizes); | |
} | |
public updateSizes(sizes: string[]) { | |
this.sizes = sizes; | |
} | |
public addTopping(topping: string) { | |
this.toppings.push(topping); | |
} | |
} | |
const pizza = new Pizza("Peuperuni", ["small", "medium"]); | |
console.log(pizza.availableSizes); | |
pizza.updateSizes(["large, extra-large"]); | |
console.log(pizza.availableSizes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment