enum Ingredients { SUGAR, COFFE, CREAM, SALT, } enum Features { STIR, BREW, FRY, BOIL, } interface Plugin { name: '' } interface Storage { storage: [] add(item) remove(name) get(name) } class Ingredient implements Plugin() { constructor() { name: '' type: '' count: 1 } } class IngredientStore implements Storage, Plugin { constructor() { this.name = 'Ingredient Store' this.storage = [] super() } add(ingredient) { storage.push(ingredient) return storage } remove(name) { storage.remove(name) return storage } get(name) { return storage.get(name) } } class FeatureStore implements Storage, Plugin { constructor() { this.name = 'Feature Store' this.storage = [] super() } add(feature) { storage.push(feature) return storage } remove(name) { storage.remove(name) return storage } get(name) { return storage.get(name) } } class RecipeStore implements Storage, Plugin { constructor() { this.name = 'Recipe Store' this.storage = [] super() } add(recipe) { storage.push(recipe) return storage } remove(name) { storage.remove(name) return storage } get(name) { return storage.get(name) } } class USM() { constructor() { this.featureRegistry = new FeatureRegistry this.ingredientStore = new IngredientStore this.recipeStorage = new RecipeStorage } unplug(name) plug(item) addIngredient(item) addRecipe(item) cook(Recipe) printPossibleDishes() on() of() } class Feature implements Plugin() { constructor() { name: '' } perform() } class Recipe implements Plugin() { static INGREDIENTS_LIST: [] static REQUIRED_FEATURES: [] constructor() { name: '' } cook(feature, ingredients) } const UCM = new UCM const sugar = new Ingredient('sugar', 1, 'kg') const coffee = new Ingredient('coffee', 1, 'kg') UCM.addIngredient(sugar) UCM.addIngredient(coffee) const espresso = new Recipe('espresso') UCM.addRecipe(espresso) const coffeeMaker = new Feature('coffeeMaker') UCM.plug(coffeeMaker) UCM.cook('espresso')