Created
June 11, 2024 11:09
-
-
Save Caballerog/bfc122e6485ce8eb41932627da3e684d to your computer and use it in GitHub Desktop.
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
import { Ingredient } from "./ingredient"; | |
import { Recipe } from "./recipe"; | |
// Usage | |
const ingredient1 = new Ingredient("Flour", "2 cups"); | |
const ingredient2 = new Ingredient("Eggs", "3"); | |
const recipe = new Recipe("Cake"); | |
recipe.addComponent(ingredient1); | |
recipe.addComponent(ingredient2); | |
const ingredient3 = new Ingredient("Milk", "1 cup"); | |
const compositeRecipe = new Recipe("Cake with Milk"); | |
compositeRecipe.addComponent(recipe); | |
compositeRecipe.addComponent(ingredient3); | |
console.log(compositeRecipe.showDetails()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment