コード例 #1
0
ファイル: Program.cs プロジェクト: Sandell390/Automaten
        static void Main(string[] args)
        {
            int userinput = 0;


            Automat.reset();

            do
            {
                do
                {
                    Automat.Display();
                } while (Automat.CoinDeposit());


                userinput = Automat.userchoice();
            } while (Automat.Buy(userinput));



            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            bool       whileboolPro = true;
            Softdrinks sele         = new Softdrinks();

            Currency MoneyObj = new Currency();

            //get currency to softdrinks and Snack

            while (whileboolPro == true)
            {
                Console.WriteLine("Welcome to the vending machine");
                Console.WriteLine();
                Console.WriteLine("Amount of money {0}", MoneyObj.Money);
                Console.WriteLine();
                Console.WriteLine("Press: 1. input money. - 2. Snack machine. - 3. Softdrink machine. - 4. Exit.");
                int machineSelect = int.Parse(Console.ReadLine());



                switch (machineSelect)
                {
                case 1:
                    Console.WriteLine("Choose amount of money to put in");
                    MoneyObj.AddCurrency();

                    Thread.Sleep(1000);
                    Console.WriteLine("{0} have been added", MoneyObj.Money);

                    Console.Clear();
                    break;

                case 2:

                    break;

                case 3:
                    sele.SoftMethod(MoneyObj.Money);
                    break;

                case 4:
                    //Checkout function

                    Console.Clear();
                    Console.WriteLine("Calculating...");
                    Thread.Sleep(2500);
                    Console.Clear();

                    //Foreach loop displays Cartlist (items bought)

                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Your change is {0}", MoneyObj.Money);
                    Console.ForegroundColor = ConsoleColor.White;
                    whileboolPro            = false;


                    break;
                }
            }
            Automat auto = new Automat();

            auto.Snackautomat();
        }