Skip to content

Instantly share code, notes, and snippets.

@axel-andrade
Last active November 18, 2021 12:24
Show Gist options
  • Save axel-andrade/4feadb6dfd0e3cf46cf4f01d24be1133 to your computer and use it in GitHub Desktop.
Save axel-andrade/4feadb6dfd0e3cf46cf4f01d24be1133 to your computer and use it in GitHub Desktop.
enum PreparationModeType = {
COOKED: "cooked",
ROAST: "roast"
};
enum StatusPlate = {
DELIVERED: "delivered",
PREPARATION: "preparation",
WAITING: "waiting"
}
class Plate {
private ingredients: string[];
private name: string;
private preparationModeType: PreparationModeType;
private price: number;
private status: StatusPlate;
construtor(ingredients: string[], name: string, preparationModeType: PreparationModeType, price: number){
this.ingredients = ingredients;
this.name = name;
this.preparationModeType = preparationModeType;
this.price = price;
this.status = StatusPlate.WAITING;
}
public cook(): void {
this.status = StatusPlate.PREPARATION
// method implementation
}
public roast(): void {
this.status = StatusPlate.PREPARATION
// method implementation
}
public preparePlate() {
// Need to add a plate status check here
// Check the type of preparation mode and run the preparation method
switch(preparationModeType){
case PreparationModeType.COOKED:
cook();
break;
case PreparationModeType.ROAST:
roast();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment