Skip to content

Instantly share code, notes, and snippets.

@Caballerog
Created June 11, 2024 11:08
Show Gist options
  • Save Caballerog/b5347c97b9ce42a8894f6920dc5da659 to your computer and use it in GitHub Desktop.
Save Caballerog/b5347c97b9ce42a8894f6920dc5da659 to your computer and use it in GitHub Desktop.
import { RecipeComponent } from "./recipe-component";
export class Recipe implements RecipeComponent {
name: string;
components: RecipeComponent[] = [];
constructor(name: string) {
this.name = name;
}
addComponent(component: RecipeComponent): void {
this.components.push(component);
}
showDetails(): string {
let details = `Recipe: ${this.name}\n`;
this.components.forEach(component => {
details += ` ${component.showDetails()}\n`;
});
return details;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment