Skip to content

Instantly share code, notes, and snippets.

@Caballerog
Created June 11, 2024 11:09
Show Gist options
  • Save Caballerog/bfc122e6485ce8eb41932627da3e684d to your computer and use it in GitHub Desktop.
Save Caballerog/bfc122e6485ce8eb41932627da3e684d to your computer and use it in GitHub Desktop.
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