Example #1
0
 //Check input Coins and DrinkPrice
 public static int CollectMoney(decimal price, decimal total, DaisyMachine newDaisyMachine, VendingMachineDrink newDrink)
 {
     decimal change = total - price;
     if (total == price)
     { 
         Console.Clear();
         newDaisyMachine.PrepareDrink(newDrink);
         GiveChange.PayChangeBack(change);
         FinalPicture.displayPicture();
         Console.Beep(700, 1000);
         return 1;
     }
     else if (total > price)
     {
         Console.Clear();
         newDaisyMachine.PrepareDrink(newDrink);
         GiveChange.PayChangeBack(change);
         FinalPicture.displayPicture();
         Console.Beep(700, 5000);
         return 1;
     }
     else
     {
         decimal more = price - total;
         Console.WriteLine("Please insert: {0}лв.", more);
         return 2;
     }
 }
Example #2
0
 public static int CheckDrink(decimal total, ConsoleKeyInfo inputCode, DaisyMachine newDaisyMachine, int sug)
 {
         if (inputCode.Key == ConsoleKey.NumPad1 || inputCode.Key == ConsoleKey.D1) // Coffee
         {
             Console.WriteLine();
             VendingMachineDrink newCoffee = new VendingMachineDrink(390, 0, 0, 20, sug, 1, 1, "Coffee");
             decimal price = DrinksPrices.coffeePrice;
             return CollectMoney(price, total, newDaisyMachine, newCoffee);
         }
         else if (inputCode.Key == ConsoleKey.NumPad2 || inputCode.Key == ConsoleKey.D2) // Tea
         {
             Console.WriteLine();
             VendingMachineDrink newTea = new VendingMachineDrink(0, 50, 0, 0, sug, 1, 1, "Tea");
             decimal price = DrinksPrices.teaPrice;
             return CollectMoney(price, total, newDaisyMachine, newTea);
         }
         else if (inputCode.Key == ConsoleKey.NumPad3 || inputCode.Key == ConsoleKey.D3) // Chocolate
         {
             Console.WriteLine();
             VendingMachineDrink newChocolate = new VendingMachineDrink(0, 0, 100, 20, sug, 1, 1, "Chocolate");
             decimal price = DrinksPrices.chocolatePrice;
             return CollectMoney(price, total, newDaisyMachine, newChocolate);
         }
         else if (inputCode.Key == ConsoleKey.NumPad4 || inputCode.Key == ConsoleKey.D4) // Cappuccino
         {
             Console.WriteLine();
             VendingMachineDrink newCappuccino = new VendingMachineDrink(10, 0, 20, 50, sug, 1, 1, "Cappuccino");
             decimal price = DrinksPrices.cappuccinoPrice;
             return CollectMoney(price, total, newDaisyMachine, newCappuccino);
         }
         else
         {
             Console.WriteLine("Please insert valide DrinkCode.");
             Console.WriteLine();
             return 3;
         }
 }
Example #3
0
        static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture =
                CultureInfo.InvariantCulture;

            DaisyMachine newDaisyMachine = new DaisyMachine(1500, "Daisy Machine");
            while (true)
            {
                Console.Clear();
                StartMachine turnOnMachine = new StartMachine();
                turnOnMachine.MachineTurnOn();

                List<string> sweet = new List<string>();
                Console.WriteLine();
                Console.WriteLine("Sugar + - and press n");
                ChangeSweetness.ChangeSweet(sweet);

                int sug = sweet.Count;
                turnOnMachine.MachineTurnOn(sug);

                newDaisyMachine.DisplayQ();

                Console.WriteLine();
                Console.WriteLine("Insert Coins And press 'n' to nextStep");
                decimal total = 0.0m;
                bool done = false;
                int doneChoise = 3;
                string input = "";
                while (done == false)
                {
                    if ((total < 1.00m))
                    {
                        input = Console.ReadLine();
                        if (input != "n")
                        {
                            total = CheckMoney.CheckCoin(input, total);
                            Console.WriteLine("Total coins: {0}", total);
                        }
                        else
                        {
                            doneChoise = 3;
                            while (doneChoise == 3)
                            {
                                ConsoleKeyInfo drinkCode;
                                Console.WriteLine("Pleace select Drink Code.");
                                drinkCode = Console.ReadKey();
                                doneChoise = DesiredDrink.CheckDrink(total, drinkCode, newDaisyMachine, sug);
                                if (doneChoise == 1)
                                {
                                    done = true;
                                }
                                else if (doneChoise == 2)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        doneChoise = 3;
                        while (doneChoise == 3)
                        {
                            ConsoleKeyInfo drinkCode;
                            Console.WriteLine("Pleace select Drink Code.");
                            drinkCode = Console.ReadKey();
                            doneChoise = DesiredDrink.CheckDrink(total, drinkCode, newDaisyMachine, sug);
                            if (doneChoise == 1)
                            {
                                done = true;
                            }
                        }
                    }
                }
                newDaisyMachine.DisplayQ();
            }
        }