Skip to content

Instantly share code, notes, and snippets.

@radzserg
Created April 7, 2020 12:34
Show Gist options
  • Select an option

  • Save radzserg/a5e26991cef5c4aab5c8b1cf57eea710 to your computer and use it in GitHub Desktop.

Select an option

Save radzserg/a5e26991cef5c4aab5c8b1cf57eea710 to your computer and use it in GitHub Desktop.
class RoastedDuckReceipt {
public cook() {
console.log("Prepare the duck");
console.log("Add spices");
console.log("Roast the duck for 3 hours");
console.log("Make a sauce");
}
}
class CeasarSaladReceipt {
public cook() {
console.log("mix salmon, avocado rest of ingredients");
}
}
class DrinksReceipt {
public cook() {
console.log("Pepsi for kids");
console.log("Jack Daniels for grandfather")
}
}
class Cook {
public makeDinner() {
(new RoastedDuckReceipt()).cook();
(new CeasarSaladReceipt()).cook();
(new DrinksReceipt()).cook();
}
}
const mom = new Cook();
mom.makeDinner();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment