Exemple #1
0
        // implement abstract method PrepareDrink from IDrinkable
        public void PrepareDrink(Drink drink)
        {
            bool isEmptyMachine = (this.TheIngredients.Coffee - drink.CountCoffee >= 0) &&
                (this.TheIngredients.Tea - drink.CountTea >= 0) &&
                (this.TheIngredients.Chocolate - drink.CountChocolate >= 0  ) &&
                (this.TheIngredients.Milk - drink.CountMilk >= 0) &&
                (this.TheIngredients.Sugar - drink.CountSugar >= 0) &&
                (this.TheIngredients.Cups - drink.CountCups >= 0) &&
                (this.TheIngredients.Mixers - drink.CountMixers >= 0);

            if (isEmptyMachine == false)
            {
                
                Console.WriteLine("Low products level");
                Console.WriteLine("Take your money back.");
                Environment.Exit(0);
            }
            else
            {
                Ingredients tempIngredients = new Ingredients();
                tempIngredients = this.TheIngredients;

                tempIngredients.Coffee -= drink.CountCoffee;
                tempIngredients.Tea -= drink.CountTea;
                tempIngredients.Chocolate -= drink.CountChocolate;
                tempIngredients.Milk -= drink.CountMilk;
                tempIngredients.Sugar -= drink.CountSugar;
                tempIngredients.Cups -= drink.CountCups;
                tempIngredients.Mixers -= drink.CountMixers;

                this.TheIngredients = tempIngredients;
            }
        }
 // constructor of Daisy Machine, where we load the machine
 public DaisyMachineOffice(int machinePrice, string machineName)
     : base(machinePrice, machineName)
 {
     Ingredients loadIngredients = new Ingredients();
     loadIngredients.Coffee = this.loadCoffee;
     loadIngredients.Tea = this.loadTea;
     loadIngredients.Chocolate = this.loadChocolate;
     loadIngredients.Sugar = this.loadSugar;
     loadIngredients.Milk = this.loadMilk;
     loadIngredients.Cups = this.loadCups;
     loadIngredients.Mixers = this.loadMixers;
     this.TheIngredients = loadIngredients;
 }