public override void Run() { Console.WriteLine("********** Making a cup of Coffee **********"); var coffeePackage = new CoffeePackage() { Brand = CoffeeBrand.G7, Weight = 100m, Type = CoffeeType.Black }; var process = new CoffeeMakingProcess(); process.Handle(coffeePackage); }
public void Handle(CoffeePackage coffeePackage) { var handler = new BrandCheckingHandler(); handler.SetNextHandler(new WeightCheckingHandler()); try { handler.Handle(coffeePackage); System.Console.WriteLine("A cup of coffee has been made."); } catch (Exception exception) { System.Console.WriteLine($"No cup of coffee has been made due to {exception.Message}"); } }