Beispiel #1
0
        static void Main(string[] args)
        {
            var    choice = "";
            string userName = "", password = "";
            var    message   = new MessageToUser();
            var    inventory = new Inventory();
            var    user      = new User();
            var    bank      = new Bank();

            // Create list of a) Users and b) Articles and c) Bank accounts for users
            user.CreateUsers();
            inventory.CreateArticles();
            bank.CreateAccounts();

            //Login
            LoginUser(ref userName, ref password);

            // Write main menu and wait for input
            while (choice == "")
            {
                ClearConsole();

                Console.WriteLine("Welcome to Rikard's Vending Machine ({0})\n", userName);
                Console.WriteLine("Main menu\n");
                Console.WriteLine("A - Shop");
                Console.WriteLine("B - Bank");
                Console.WriteLine("C - Inventory");
                Console.WriteLine("D - User handling");
                Console.WriteLine("E - Change user");
                Console.WriteLine("F - Exit");
                Console.WriteLine("\nWhat do you want to do?");
                Console.Write("Select A, B, C, D or E: ");

                choice = Console.ReadLine();
                choice = choice.ToUpper();

                switch (choice)
                {
                case "A":
                    Shopping(userName);
                    break;

                case "B":
                    BankHandling(userName);
                    break;

                case "C":
                    if (user.IsUserAdmin(userName) == true)
                    {
                        InventoryHandling(userName);
                    }
                    else
                    {
                        message.Write("You do not have access to this function.");
                    }
                    break;

                case "D":
                    if (user.IsUserAdmin(userName) == true)
                    {
                        UserHandling(userName);
                    }
                    else
                    {
                        message.Write("You do not have access to this function.");
                    }
                    break;

                case "E":
                    LoginUser(ref userName, ref password);
                    break;

                case "F":
                    ClearConsole();
                    message.Write("Thanks for shopping at Rikard's Vending Machine!\nSee you soon and Welcome back!");
                    Environment.Exit(0);
                    break;

                default:
                    message.Write("Wrong option selected - Please try again!");
                    break;
                }
                choice = "";
            }
        }