Skip to content

Instantly share code, notes, and snippets.

@axel-andrade
Last active January 13, 2022 13:33
Show Gist options
  • Save axel-andrade/228f9ad6af072a0d2732cb5e31edf00c to your computer and use it in GitHub Desktop.
Save axel-andrade/228f9ad6af072a0d2732cb5e31edf00c to your computer and use it in GitHub Desktop.
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