Пример #1
0
        //add Protocol
        public void AddP()
        {
            Dptions("Protocol");
            Console.WriteLine("==========================================================================");
            Droid newProtocol = new Protocol(materailSelect, "Protocol", colorSelect, numLangauges);

            droidCollection.Add(newProtocol);
            newProtocol.CalculateBaseCost();
            newProtocol.CalculateTotalCost();
            totalCost += newProtocol.totalCost;
            Console.WriteLine("COLLECTED: " + newProtocol);
            Console.WriteLine("==========================================================================");
            Console.WriteLine();
        }
Пример #2
0
        // this method is designed to add a new droid to the droid list
        private void AddDroid()
        {
            Console.WriteLine("Input Droid ID Number");
            string droidNumber = Convert.ToString(Console.ReadLine().ToUpper());

            Console.WriteLine("Select Droid Type");
            Console.WriteLine("1: Protocol");
            Console.WriteLine("2: Utility");
            string droidType = Convert.ToString(Console.ReadLine());

            string droidModel = "NULL";

            if (droidType == "2")
            {
                droidType = "Utility";
                Console.WriteLine("Select Droid Model");
                Console.WriteLine("1: Janitor");
                Console.WriteLine("2: Astromech");
                droidModel = Convert.ToString(Console.ReadLine());

                if (droidModel == "1")
                {
                    Janitor newDroid = new Janitor();
                }

                else
                {
                    Astromech newDroid = new Astromech();
                }
            }

            else
            {
                Protocol newDroid = new Protocol();
            }

            Console.WriteLine("Input Droid's Body Color");
            string droidBColor = Convert.ToString(Console.ReadLine().ToUpper());

            Console.WriteLine("Input Droid's Detail Color");
            string droidDColor = Convert.ToString(Console.ReadLine().ToUpper());

            Console.WriteLine("Input Droid's Primary Material");
            string droidMaterial = Convert.ToString(Console.ReadLine().ToUpper());



            string content = droidNumber + " " + droidType + " " + droidModel + " " + droidBColor + " " + droidDColor + " " + droidMaterial;

            dC.Add(content);
        }
Пример #3
0
        public static UIMenu AstromechDroidMenu = new UIMenu();                                                        // Astromech Droid Menu

        static void Main(string[] args)
        {
            // Populate menus
            populateMenus();

            // Initialize the console window
            UserInterface.InitializeConsoleWindow("Droid Creator");

            // Main program loop
            do
            {
                // Print the main menu and get an answer from the user
                int menuChoice = UserInterface.GetMainMenuSelection(MenuSelections, "Droid Making Program");

                // Make a choice depending on the menu selection
                switch (menuChoice)
                {
                // Add a droid
                case 1:
                    // General pattern here is 1) draw the menu 2) declare value variables 3) get the values from the menu elements and assign them to the value variables

                    // Variable to hold the new droid
                    Droid assembledDroid = null;

                    #region Droid Variables
                    // Variables to hold values that will be used to create a new droid
                    Droid.DroidMaterial material = Droid.DroidMaterial.AGRINIUM;
                    Droid.DroidColor    color    = Droid.DroidColor.BLACK;
                    Droid.DroidModel    model    = Droid.DroidModel.ASTROMECH;

                    int numberOfLanguages = 0;

                    bool hasToolbox            = false;
                    bool hasComputerConnection = false;
                    bool hasArm = false;

                    bool hasTrashCompactor = false;
                    bool hasVacuum         = false;

                    bool hasFireExtinguisher = false;
                    int  numberOfShips       = 0;
                    #endregion

                    // Start menu
                    GeneralDroidMenu.Start();

                    #region General Droid Handling
                    // Get handle to UI elements
                    SelectionBox materialBox = (SelectionBox)GeneralDroidMenu.GetElementByTitle("material:");
                    SelectionBox colorBox    = (SelectionBox)GeneralDroidMenu.GetElementByTitle("color:");
                    SelectionBox modelBox    = (SelectionBox)GeneralDroidMenu.GetElementByTitle("model:");

                    // Extract and assign data from elements
                    Enum.TryParse <Droid.DroidMaterial>(materialBox.SelectedText, out material);
                    Enum.TryParse <Droid.DroidColor>(colorBox.SelectedText, out color);
                    Enum.TryParse <Droid.DroidModel>(modelBox.SelectedText, out model);
                    #endregion

                    #region Protocol and Utility Droid Handling
                    // Decide which menu to show next based on what they entered for "model"
                    switch (model)
                    {
                    case Droid.DroidModel.PROTOCOL:                 // For the protocol droid...

                        // Start the menu
                        ProtocolDroidMenu.Start();

                        // Get handle to UI element
                        SelectionBox numLanguagesBox = (SelectionBox)ProtocolDroidMenu.GetElementByTitle("number of languages:");

                        // Extract and assign data from element
                        int.TryParse(numLanguagesBox.SelectedText, out numberOfLanguages);

                        break;

                    case Droid.DroidModel.UTILITY:                  // For the utility, janitor, and astromech droids...
                    case Droid.DroidModel.JANITOR:
                    case Droid.DroidModel.ASTROMECH:

                        // Start the menu
                        UtilityDroidMenu.Start();

                        // Get handle to UI elements
                        SelectionBox hasToolboxBox            = (SelectionBox)UtilityDroidMenu.GetElementByTitle("toolbox:");
                        SelectionBox hasComputerConnectionBox = (SelectionBox)UtilityDroidMenu.GetElementByTitle("computer connection:");
                        SelectionBox hasArmBox = (SelectionBox)UtilityDroidMenu.GetElementByTitle("arm:");

                        // Extract and assign data from elements
                        bool.TryParse(hasToolboxBox.SelectedText, out hasToolbox);
                        bool.TryParse(hasComputerConnectionBox.SelectedText, out hasComputerConnection);
                        bool.TryParse(hasArmBox.SelectedText, out hasArm);

                        #region Janitor and Astromech Droid Handling

                        // Take care of the janitor and astromech droids
                        switch (model)
                        {
                        case Droid.DroidModel.JANITOR:                      // For the janitor droid...

                            // Start the menu
                            JanitorDroidMenu.Start();

                            // Get handle to UI elements
                            SelectionBox hasTrashCompactorBox = (SelectionBox)JanitorDroidMenu.GetElementByTitle("trash compactor:");
                            SelectionBox hasVacuumBox         = (SelectionBox)JanitorDroidMenu.GetElementByTitle("vacuum:");

                            // Extract and assign data from elements
                            bool.TryParse(hasTrashCompactorBox.SelectedText, out hasTrashCompactor);
                            bool.TryParse(hasVacuumBox.SelectedText, out hasVacuum);

                            break;

                        case Droid.DroidModel.ASTROMECH:                    // For the astromech droid...

                            // Start the menu
                            AstromechDroidMenu.Start();

                            // Get handle to UI elements
                            SelectionBox hasFireExtinguisherBox = (SelectionBox)AstromechDroidMenu.GetElementByTitle("fire extinguisher:");
                            SelectionBox numberOfShipsBox       = (SelectionBox)AstromechDroidMenu.GetElementByTitle("number of ships:");

                            // Extract and assign data from elements
                            bool.TryParse(hasFireExtinguisherBox.SelectedText, out hasFireExtinguisher);
                            int.TryParse(numberOfShipsBox.SelectedText, out numberOfShips);

                            break;
                        }
                        #endregion

                        break;
                    }
                    #endregion


                    // Based on what the user entered, create a new droid from that data
                    switch (model)
                    {
                    case Droid.DroidModel.PROTOCOL:
                        assembledDroid = new ProtocolDroid(material, model, color, numberOfLanguages);
                        break;

                    case Droid.DroidModel.UTILITY:
                        assembledDroid = new UtilityDroid(material, model, color, hasToolbox, hasComputerConnection, hasArm);
                        break;

                    case Droid.DroidModel.JANITOR:
                        assembledDroid = new JanitorDroid(material, model, color, hasToolbox, hasComputerConnection, hasArm, hasTrashCompactor, hasVacuum);
                        break;

                    case Droid.DroidModel.ASTROMECH:

                        break;
                    }

                    // FINALLY, add the assembled droid to the list
                    DroidCollection.Add(assembledDroid);

                    // Clear screen
                    UserInterface.ClearScreen();

                    // Draw status
                    UserInterface.SetStatus(UserInterface.PressAnyPhrase(assembledDroid.Model + " droid added to droid list!"));

                    // Wait for user to press a key
                    Console.ReadKey(true);

                    break;

                // List the droids
                case 2:
                    UserInterface.ListDroids();
                    break;

                // Exit program
                case 3:
                    System.Environment.Exit(0);
                    break;
                }
            } while (true);
        }