Last active
January 13, 2022 13:33
-
-
Save axel-andrade/228f9ad6af072a0d2732cb5e31edf00c to your computer and use it in GitHub Desktop.
This file contains 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
enum StatusPlate = { | |
DELIVERED: "delivered", | |
PREPARATION: "preparation", | |
WAITING: "waiting" | |
} | |
interface Plate { | |
getStatusPlate(): StatusPlate; | |
preparatePlate(): void; | |
} | |
class CookedPlate implements Plate { | |
private ingredients: string[]; | |
private name: string; | |
private price: number; | |
private status: StatusPlate; | |
construtor(ingredients: string[], name: string, price: number){ | |
this.ingredients = ingredients; | |
this.name = name; | |
this.price = price; | |
this.status = StatusPlate.WAITING; | |
} | |
private cook(): void { | |
this.status = StatusPlate.PREPARATION | |
// method implementation | |
} | |
public getStatusPlate(): StatusPlate { | |
return this.status; | |
} | |
public preparePlate(): void { | |
// Need to add a plate status check here | |
cook(); | |
} | |
} | |
class FlyPlate implements Plate { | |
private ingredients: string[]; | |
private name: string; | |
private price: number; | |
private status: StatusPlate; | |
construtor(ingredients: string[], name: string, price: number){ | |
this.ingredients = ingredients; | |
this.name = name; | |
this.price = price; | |
this.status = StatusPlate.WAITING; | |
} | |
private fly(): void { | |
this.status = StatusPlate.PREPARATION | |
// method implementation | |
} | |
public getStatusPlate(): StatusPlate { | |
return this.status; | |
} | |
public preparePlate(): void { | |
// Need to add a plate status check here | |
fly(); | |
} | |
} | |
class RoastPlate implements Plate { | |
private ingredients: string[]; | |
private name: string; | |
private price: number; | |
private status: StatusPlate; | |
construtor(ingredients: string[], name: string, price: number){ | |
this.ingredients = ingredients; | |
this.name = name; | |
this.price = price; | |
this.status = StatusPlate.WAITING; | |
} | |
private roast(): void { | |
this.status = StatusPlate.PREPARATION | |
// method implementation | |
} | |
public getStatusPlate(): StatusPlate { | |
return this.status; | |
} | |
public preparePlate(): void { | |
// Need to add a plate status check here | |
roast(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment