Пример #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);

            //Add 10 hard coded droids to the collections
            droidCollection.Add("Carbonite", "Protocol", "Silver", 10);                              //Protocol $350
            droidCollection.Add("Vanadium", "Astromech", "Gold", true, true, true, false, 2);        //Astromech $315
            droidCollection.Add("Carbonite", "Janitorial", "Bronze", false, true, true, true, true); //Janitorial $240
            droidCollection.Add("Quadranium", "Utility", "Silver", true, true, true);                //Utility $255
            droidCollection.Add("Carbonite", "Astromech", "Bronze", false, false, false, false, 1);  //Astromech $145
            droidCollection.Add("Vanadium", "Utility", "Silver", true, false, true);                 //Utility $190
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 1);                               //Protocol $125
            droidCollection.Add("Quadranium", "Astromech", "Gold", true, true, true, true, 10);      //Astromech $740
            droidCollection.Add("Vanadium", "Utility", "Gold", false, false, true);                  //Utility $155
            droidCollection.Add("Vanadium", "Janitorial", "Bronze", true, true, true, true, true);   //Janitorial $295

            //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;
                    //Sort droids by model
                    case 3:
                        break;
                    //sort droids by cost
                    case 4:
                        break;

                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #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);

            //Add 12 random droids
            droidCollection.Add(12);

            //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;

                //Choose to organize droids by type
                case 3:
                    userInterface.Organize();
                    break;

                //Choose to sort droids by total cost
                case 4:
                    userInterface.Sort();
                    break;

                case 5:
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);
            //Add 12 random droids
            droidCollection.Add(12);

            //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;

                    //Choose to organize droids by type
                    case 3:
                        userInterface.Organize();
                        break;

                    //Choose to sort droids by total cost
                    case 4:
                        userInterface.Sort();
                        break;

                    case 5:
                        break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #4
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 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:
                    droidCollection.CategorizeByModel();
                    break;

                case 4:
                    droidCollection.SortByPrice();
                    break;

                case 5:
                    Environment.Exit(0);
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #5
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();
            }
        }
Пример #6
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();
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            DroidCollection droidCollection = new DroidCollection(100);

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

            // Load in 12 droids for easier testing:
            droidCollection.PreloadDroids();

            //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 5, 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;

                // Sort the droids by type:
                case 3:
                    droidCollection.SortDroidsByType();

                    // Output confirmation to user:
                    Console.WriteLine();
                    Console.WriteLine("Droids have been sorted by type!");
                    Console.WriteLine();
                    break;

                // Sort the droids by cost:
                case 4:
                    droidCollection.SortDroidsByPrice();

                    // Output confirmation to user:
                    Console.WriteLine();
                    Console.WriteLine("Droids have been sorted by cost!");
                    Console.WriteLine();
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #8
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 user interface and pass the droidCollection into it as a dependency
            UserInterface userInterface = new UserInterface(droidCollection);

            //Creates a merge sort class.
            MergeSort mergeSort = new MergeSort();

            //Example droids for use in testing the program.
            //9 droids to make sure it works even with odd numbered arrays/lists.
            droidCollection.Add("Carbonite", "Utility", "Bronze", true, true, true);
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 3);
            droidCollection.Add("Carbonite", "Astromech", "Bronze", true, true, true, true, 5);
            droidCollection.Add("Carbonite", "Janitor", "Bronze", true, true, true, true, true);

            droidCollection.Add("Carbonite", "Utility", "Silver", true, true, true);
            droidCollection.Add("Carbonite", "Protocol", "Silver", 3);
            droidCollection.Add("Carbonite", "Astromech", "Silver", true, true, true, true, 5);
            droidCollection.Add("Carbonite", "Janitor", "Silver", true, true, true, true, true);

            droidCollection.Add("Vanadium", "Protocol", "Gold", 6);

            //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 5, 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;
                    //Choose to sort the list by droid type
                    case 3:
                        droidCollection.SortByDroid();
                        break;
                    //Chose to sort the list by droid total price
                    case 4:
                        droidCollection.SortByPrice();
                        break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #9
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 user interface and pass the droidCollection into it as a dependency
            UserInterface userInterface = new UserInterface(droidCollection);

            //Creates a merge sort class.
            MergeSort mergeSort = new MergeSort();

            //Example droids for use in testing the program.
            //9 droids to make sure it works even with odd numbered arrays/lists.
            droidCollection.Add("Carbonite", "Utility", "Bronze", true, true, true);
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 3);
            droidCollection.Add("Carbonite", "Astromech", "Bronze", true, true, true, true, 5);
            droidCollection.Add("Carbonite", "Janitor", "Bronze", true, true, true, true, true);

            droidCollection.Add("Carbonite", "Utility", "Silver", true, true, true);
            droidCollection.Add("Carbonite", "Protocol", "Silver", 3);
            droidCollection.Add("Carbonite", "Astromech", "Silver", true, true, true, true, 5);
            droidCollection.Add("Carbonite", "Janitor", "Silver", true, true, true, true, true);

            droidCollection.Add("Vanadium", "Protocol", "Gold", 6);



            //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 5, 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;

                //Choose to sort the list by droid type
                case 3:
                    droidCollection.SortByDroid();
                    break;

                //Chose to sort the list by droid total price
                case 4:
                    droidCollection.SortByPrice();
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #10
0
        static void Main(string[] args)
        {
            //Instanciates some a queue and a stack for each type of droid
            DroidQueue <IDroid> queue          = new DroidQueue <IDroid>();
            DroidStack <IDroid> protocolStack  = new DroidStack <IDroid>();
            DroidStack <IDroid> utilityStack   = new DroidStack <IDroid>();
            DroidStack <IDroid> astromechStack = new DroidStack <IDroid>();
            DroidStack <IDroid> janitorStack   = new DroidStack <IDroid>();

            //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, queue, astromechStack, janitorStack, utilityStack, protocolStack);


            //Here, have a whole bunch of pre-created droids to use for testing! Some minor typos in these when I first typed em gave me quite a headache.

            droidCollection.Add("Carbonite", "Protocol", "Gold", 7);
            droidCollection.Add("Vanadium", "Protocol", "Silver", 10);
            droidCollection.Add("Vanadium", "Astromech", "Silver", true, false, true, true, 5);
            droidCollection.Add("Carbonite", "Astromech", "Gold", false, true, true, true, 3);
            droidCollection.Add("Carbonite", "Utility", "Gold", false, true, false);
            droidCollection.Add("Vanadium", "Utility", "Silver", true, false, true);
            droidCollection.Add("Carbonite", "Janitorial", "Gold", true, false, true, false, true);
            droidCollection.Add("Vanadium", "Janitorial", "Silver", true, true, false, false, true);


            //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;

                //Choose to Sort by Model
                case 3:
                    userInterface.SortDroidListByModel();
                    break;

                //Choose to sort by cost.
                case 4:
                    userInterface.SortDroidListByCost();
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #11
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();
            }
        }
Пример #12
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 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();

            //*****************
            //Hard coded Droids
            //*****************
            //Todo, change to droid stack
            droidCollection.Add("Quadranium", "Protocol", "Gold", 10);
            droidCollection.Add("Vanadium", "Astromech", "Silver", true, true, false, true, 3);
            droidCollection.Add("Quadranium", "Utility", "Silver", false, false, true);
            droidCollection.Add("Carbonite", "Janitor", "Bronze", true, false, true, true, true);
            droidCollection.Add("Vanadium", "Janitor", "Silver", false, true, false, false, false);
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 6);
            droidCollection.Add("Carbonite", "Utility", "Gold", true, true, true);
            droidCollection.Add("Quadranium", "Astromech", "Gold", false, false, false, false, 10);
            droidCollection.Add("Quadranium", "Janitor", "Gold", true, true, true, true, true);
            droidCollection.Add("Vanadium", "Protocol", "Silver", 13);
            droidCollection.Add("Carbonite", "Astromech", "Gold", false, true, false, true, 7);
            droidCollection.Add("Vanadium", "Utility", "Silver", true, false, true);


            //While the choice is not equal to 5, 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;

                //****************
                //New Menu Options
                //****************

                //Choose to Categorize by Model
                case 3:
                    droidCollection.CategorizeModels();
                    userInterface.Display("Categorized Successfully");
                    break;

                //Choose to Sort total cost
                case 4:
                    droidCollection.MergeSort();
                    userInterface.Display("Merge Sort Successful");
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);

            //Adding some droids to the collection for testing purposes
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 20);
            droidCollection.Add("Carbonite", "Utility", "Silver", false, true, true);
            droidCollection.Add("Carbonite", "Janitor", "Gold", false, true, true, false, true);
            droidCollection.Add("Vanadium", "Astromech", "Bronze", false, true, false, true, 10);
            droidCollection.Add("Vanadium", "Protocol", "Silver", 40);
            droidCollection.Add("Vanadium", "Utility", "Gold", true, false, true);
            droidCollection.Add("Quadranium", "Janitor", "Bronze", true, false, true, true, false);
            droidCollection.Add("Quadranium", "Astromech", "Silver", true, true, true, true, 50);
            droidCollection.Add("Quadranium", "Protocol", "Gold", 60);
            droidCollection.Add("Carbonite", "Utility", "Bronze", false, false, true);
            droidCollection.Add("Vanadium", "Janitor", "Silver", true, false, true, false, true);
            droidCollection.Add("Quadranium", "Astromech", "Gold", true, true, true, true, 75);

            //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;

                //Choose to Sort the droids by model
                case 3:
                    userInterface.ModelSort();
                    break;

                //Choose to Sort the droids by total cost
                case 4:
                    userInterface.CostSort();
                    break;
                }
                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }
Пример #14
0
        static void Main(string[] args)
        {
            //Create a new droid collection and set the size of it to 100.
            IDroidCollection droidCollection = new DroidCollection(100);



            //Hardcode droids to collection, varied to prove sort works, put in groups of 4
            //Set 1
            //Protocol
            droidCollection.Add("Carbonite", "Protocol", "Bronze", 4);
            //Astromech
            droidCollection.Add("Vanadium", "Astromech", "Silver", true, true, true, false, 4);
            //Utility
            droidCollection.Add("Quadranium", "Utility", "Gold", true, true, true);
            //Janitor
            droidCollection.Add("Carbonite", "Janitor", "Silver", true, true, false, false, true);

            //Set 2
            //Protocol
            droidCollection.Add("Vanadium", "Protocol", "Gold", 7);
            //Astromech
            droidCollection.Add("Quadranium", "Astromech", "Silver", false, true, true, false, 5);
            //Utility
            droidCollection.Add("Carbonite", "Utility", "Bronze", true, true, false);
            //Janitor
            droidCollection.Add("Carbonite", "Janitor", "Gold", false, true, true, false, true);

            //Set 3
            //Protocol
            droidCollection.Add("Vanadium", "Protocol", "Gold", 6);
            //Astromech
            droidCollection.Add("Vanadium", "Astromech", "Bronze", true, false, false, false, 2);
            //Utility
            droidCollection.Add("Quadranium", "Utility", "Silver", false, true, true);
            //Janitor
            droidCollection.Add("Quadranium", "Janitor", "Gold", true, true, true, 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;

                //Choose to sort by model
                case 3:
                    userInterface.sortModel();
                    break;

                //Choose to sort by total cost

                case 4:
                    userInterface.sortCost();
                    break;
                }

                //Re-display the menu, and re-prompt for the choice
                userInterface.DisplayMainMenu();
                choice = userInterface.GetMenuChoice();
            }
        }