Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);

            //Create a few droids to put into the list so that they do not NEED to be made through the UI
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 12);
            droidCollection.Add("Vanadium", "Utility", "Gold", true, true, true);
            droidCollection.Add("Vanadium", "Janitor", "Silver", true, true, true, true, true);
            droidCollection.Add("Carbonite", "Astromech", "Bronze", true, true, false, true, 80);
            droidCollection.Add("Quadranium", "Protocol", "Silver", 22);
            droidCollection.Add("Carbonite", "Janitor", "Bronze", false, false, false, false, true);
            droidCollection.Add("Vanadium", "Utility", "Gold", true, true, false);
            droidCollection.Add("Quadranium", "Astromech", "Silver", false, true, false, true, 150);
            droidCollection.Add("Quadranium", "Janitor", "Gold", false, true, true, true, true);
            droidCollection.Add("Vanadium", "Utility", "Gold", true, false, true);
            droidCollection.Add("Carbonite", "Astromech", "Bronze", true, false, false, true, 100);
            droidCollection.Add("Carbonite", "Janitor", "Silver", false, true, false, true, true);

            //Create a user interface and pass the droidCollection into it as a dependency
            UserInterface userInterface = new UserInterface(droidCollection);

            //Display the main greeting for the program
            userInterface.DisplayGreeting();

            //Display the main menu for the program
            userInterface.DisplayMainMenu();

            //Get the choice that the user makes
            int choice = userInterface.GetMenuChoice();

            //While the choice is not equal to 3, continue to do work with the program
            while (choice != 5)
            {
                //Test which choice was made
                switch (choice)
                {
                    //Choose to create a droid
                    case 1:
                        userInterface.CreateDroid();
                        break;

                    //Choose to Print the droid
                    case 2:
                        userInterface.PrintDroidList();
                        break;

                    case 3:
                        //Print in categorical order
                        droidCollection.SortIntoCategories();
                        userInterface.DisplaySortCategoriesSuccessMessage();
                        break;

                    case 4:
                        //Print in Total Cost order
                        droidCollection.SortByTotalCost();
                        userInterface.DisplaySortTotalCostSuccessMessage();
                        break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }