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 Cupon { | |
static allowed = ["Peepurini", "Blazing Fluerino"]; | |
static create(percentage: number) { | |
return `PIZZA_RESTURANT_${percentage}%`; | |
} | |
} | |
console.log(Cupon.create(25)); |
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
interface SizesInterface { | |
availableSizes: string[]; | |
} | |
abstract class Sizes implements SizesInterface { | |
constructor(protected sizes: string[]) {} | |
set availableSizes(sizes: string[]) { | |
this.sizes = sizes; | |
} |
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; | |
} |
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(public sizes: string[]) {} | |
set availableSizes(sizes: string[]) { | |
this.sizes = sizes; | |
} | |
get availableSizes() { | |
return this.sizes; | |
} |
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; | |
} |
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; | |
} |
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 Pizza { | |
public toppings: string[] = []; | |
constructor(readonly name: string) {} | |
public addToping(topping: string) { | |
this.toppings.push(topping); | |
} | |
} |
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 Pizza { | |
public toppings: string[] = []; | |
constructor(private name: string) {} | |
public addTopping(topping: string) { | |
this.toppings.push(topping); | |
} | |
} |
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 Pizza { | |
name: string; | |
toppings: string[] = []; | |
constructor(name: string) { | |
this.name = name; | |
} | |
addTopping(topping: string) { | |
this.toppings.push(topping); |
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
interface Sizes { | |
sizes: string[]; | |
} | |
interface Pizza extends Sizes { | |
name: string; | |
toppings?: number; | |
getAvailableSizes(): void; | |
[key: number]: string; // TypeScript index signatures must either be a ´string´ or a ´number´ | |
} |