Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //bool dontexit = true;

            //PRINT WELCOME HEADER
            Console.WriteLine("    Jawa Droid Manager" + Environment.NewLine);
            Console.WriteLine("         ,-----.{0}       ,'_/_|_\\_`.{0}      /<<::8[O]::>\\{0}     _|-----------|_{0} :::|  | ====-=- |  |:::{0} :::|  | -=-==== |  |:::{0} :::\\  | ::::|()||  /:::{0} ::::| | ....|()|| |::::{0}     | |_________| |{0}     | |\\_______/| |{0}    /   \\ /   \\ /   \\{0}    `---' `---' `---'{0}", Environment.NewLine);

            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);

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

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

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

            while (choice != 5)
            {
                //Test which choice was made
                switch (choice)
                {
                    case 1:
                        userInterface.CreateDroid();
                        break;
                    case 2:
                        userInterface.ColorCodeDroidList();
                        break;
                    case 3:
                        droidCollection.SortByModel();
                        userInterface.ColorCodeDroidList();
                        break;
                    case 4:
                        droidCollection.SortByCost();
                        userInterface.ColorCodeDroidList();
                        break;
                    default:
                        userInterface.DisplayError();
                        break;
                }

            //Re-display the menu, and re-prompt for the choice
            userInterface.DisplayMainMenu();
            choice = userInterface.GetMenuChoice();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);

            // Initial collection of droids
            droidCollection.Add("Bronze", "Protocol", "Blue", 5);
            droidCollection.Add("Bronze", "Protocol", "green", 6);
            droidCollection.Add("Bronze", "Janitor", "yellow", false, true, true, false, false);
            droidCollection.Add("Bronze", "Astromech", "Blue", true, false, true, true, 4);
            droidCollection.Add("Bronze", "Utility", "Blue", true, false, true);
            droidCollection.Add("Bronze", "Astromech", "Red", true, true, true, true, 8);
            droidCollection.Add("Bronze", "Utility", "green", false, false, true);
            droidCollection.Add("Bronze", "Janitor", "red", true, false, true, true, false);
            droidCollection.Add("Bronze", "Janitor", "Blue", true, true, false, true, false);
            droidCollection.Add("Bronze", "Protocol", "red", 2);
            droidCollection.Add("Bronze", "Utility", "red", true, true, false);
            droidCollection.Add("Bronze", "Astromech", "yellow", true, false, true, false, 2);

            //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:
                    // Output the droid collection before and after sorting
                    userInterface.Output("---------------- Before Sort ----------------");
                    userInterface.PrintDroidList();
                    userInterface.Output("---------------- After Sort ----------------");
                    droidCollection.SortByModel();
                    userInterface.PrintDroidList();
                    break;

                case 4:
                    // Output the droid collection before and after sorting
                    userInterface.Output("---------------- Before Sort ----------------");
                    userInterface.PrintDroidList();
                    userInterface.Output("---------------- After Sort ----------------");
                    droidCollection.SortByCost();
                    userInterface.PrintDroidList();
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }