Exemplo n.º 1
0
 public void AddUtilityDroid()                                                                               //method used for adding a Utilty droid
 {
     model              = "Utility";                                                                         //model is named Utility
     material           = userInterface.GetDroidMaterial();                                                  //user interface asks user which material to pick from
     color              = userInterface.GetDroidColor();                                                     //user interface asks user which color to pick from
     toolbox            = userInterface.GetToolbox();                                                        //user interface asks user if they want a toolbox for their droid
     computerConnection = userInterface.GetCompConnection();                                                 //user interface asks user if they want a computer connection for their droid
     arm = userInterface.GetArm();                                                                           //user interface asks user if they want an extra arm for their droid
     droids[positionInArray] = new UtilityDroid(material, model, color, toolbox, computerConnection, arm);   //final droid is added to the array
     totalCost = droids[positionInArray].CalculateTotalCost();                                               //total cost is determined based on droid type
     Console.WriteLine(Environment.NewLine + "Final Specs:" +                                                //droid specs are printed to the console for the user to see
                       Environment.NewLine + droids[positionInArray] + " " + totalCost.ToString("C") +
                       Environment.NewLine);
     positionInArray++;                                                                                      //array index is changed so the recently added droid will not be overwritten
 }
Exemplo n.º 2
0
        /// <summary>
        /// adds a droid to the inventory
        /// </summary>
        private void addDroid()
        {
            Console.WriteLine("please choose a droid type:");
            for (int i = 0; i < listOfPrices.Length; i++)
            {
                Console.WriteLine((i + 1) + ": " + listOfPrices[i].model);
            }
            String selection = Console.ReadLine();
            int    selectionInt;

            Console.Clear();
            if (int.TryParse(selection, out selectionInt) && selectionInt <= listOfPrices.Length)
            {
                Console.WriteLine(listOfPrices[selectionInt - 1].model + Environment.NewLine);
                switch (listOfPrices[selectionInt - 1].model)
                {
                case "astromech":
                    Inventory.Add(AstromechDroid.CreateDroid());
                    break;

                case "protocol":
                    Inventory.Add(ProtocolDroid.CreateDroid());
                    break;

                case "janitor":
                    Inventory.Add(JanitorDroid.CreateDroid());
                    break;

                case "utility":
                    Inventory.Add(UtilityDroid.CreateDroid());
                    break;

                default:
                    Console.WriteLine("Error, unknown droid type");
                    break;
                }
                Console.Clear();
            }
            else
            {
                Console.WriteLine("invalid Input, {0}", selection);
            }
        }
        int _freeSpot = 0; // >Marks the location to add a new droid.

        #endregion Fields

        #region Methods

        // >Add a droid to the list.
        public void AddADroid()
        {
            int modelChoice = 0;
            string newDroidModel = string.Empty;
            string newDroidMaterial = string.Empty;
            string newDroidColor = string.Empty;

            // >Set the model.
            SelectModel(ref newDroidModel, ref modelChoice);
            // >Set the material.
            SelectMaterial(ref newDroidMaterial);
            // >Set the color.
            SelectColor(ref newDroidColor);

            // >These choices depend on the model chosen.
            switch (modelChoice)
            {
                // >MC stands for Model Catagory.
                case PROTOCOL_MC:
                    int newDroidNumOfLanguages = 0;// >The number of languages that the droid knows.

                    // >Select the number of languages.
                    SelectNumberOfLanquages(ref newDroidNumOfLanguages);

                    // >Create a new droid in the array's free spot.
                    droidsArray[_freeSpot] = new ProtocolDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidNumOfLanguages);
                    break;
                case UTILITY_MC:
                case JANITOR_MC:
                case ASTROMECH_MC:
                    bool newDroidToolBox = false;// >If the droid has a toolbox.
                    bool newDroidComputerConnection = false;// >If the droid has a computer connection.
                    bool newDroidArm = false;// >If the droid has and newDroidArm.

                    // >set if it has a tool box.
                    SelectToolBoxBool(ref newDroidToolBox);
                    // >Set if it has a computer connection.
                    SelectComputerConnectionBool(ref newDroidComputerConnection);
                    // >Set if it has an arm.
                    SelectArmBool(ref newDroidArm);

                    if (modelChoice == UTILITY_MC)
                    {
                        // >Create a new droid in the array's free spot.
                        droidsArray[_freeSpot] = new UtilityDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm);
                    }
                    else
                    {
                        switch (modelChoice)
                        {
                            case JANITOR_MC:
                                bool newDroidTrashCompactor = false;// >If the droid has a trash compactor.
                                bool newDroidVacuum = false;// >If the droid has a vacuum.

                                // >Set if it has a trash compactor.
                                SelectTrashCompactorBool(ref newDroidTrashCompactor);
                                // >Set if it has a vacuum.
                                SelectVacuumBool(ref newDroidVacuum);

                                // >Create a new droid in the array's free spot.
                                droidsArray[_freeSpot] = new JanitorDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm, newDroidTrashCompactor, newDroidVacuum);
                                break;
                            case ASTROMECH_MC:
                                bool newDroidFireExtinquisher = false;// >If the droid has a FireExtinquisher.
                                int newDroidNumberOfShips = 0;// >The number of ships the droid has worked on.

                                // >Set if it has a FireExtinquisher.
                                SelectFireExtinquisherBool(ref newDroidFireExtinquisher);

                                // >Set the number of ships worked on.
                                SelectNumberOfShips(ref newDroidNumberOfShips);

                                // >Create a new droid in the array's free spot.
                                droidsArray[_freeSpot] = new AstromechDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm, newDroidFireExtinquisher, newDroidNumberOfShips);
                                break;
                        }
                    }
                    break;
            }
            // >Inform the user that the addition was successful.
            UserInterface.WriteToScreen("");
            UserInterface.WriteToScreen("-- The droid has been added to the list --");
            UserInterface.WriteToScreen("");

            // >Change the free spot.
            _freeSpot++;
        }
 public void add(string model, string material, string color, bool toolbox, bool computer, bool arm)
 {
     droids[currentIndex++] = new UtilityDroid(model, material, color, toolbox, computer, arm);
 }
        /// <summary>
        /// Add a Utility Droid
        /// </summary>
        /// <param name="material">The material string name</param>
        /// <param name="model">The model string text</param>
        /// <param name="color">The color string name</param>
        /// <param name="toolbox">Does this Droid have a toolbox?</param>
        /// <param name="computerConnection">Does this Droid have a computer connection?</param>
        /// <param name="arm">Does this Droid have an arm?</param>
        public void AddDroid(string material, string model, string color, bool toolbox, bool computerConnection, bool arm)
        {
            UtilityDroid droid = new UtilityDroid(material, model, color, toolbox, computerConnection, arm);

            this.AddDroid(droid);
        }
        Droid[] droidsArray = new Droid[100]; // >Holds all of the droids.



        // >Add a droid to the list.
        public void AddADroid()
        {
            int    modelChoice      = 0;
            string newDroidModel    = string.Empty;
            string newDroidMaterial = string.Empty;
            string newDroidColor    = string.Empty;

            // >Set the model.
            SelectModel(ref newDroidModel, ref modelChoice);
            // >Set the material.
            SelectMaterial(ref newDroidMaterial);
            // >Set the color.
            SelectColor(ref newDroidColor);

            // >These choices depend on the model chosen.
            switch (modelChoice)
            {
            // >MC stands for Model Catagory.
            case PROTOCOL_MC:
                int newDroidNumOfLanguages = 0;    // >The number of languages that the droid knows.

                // >Select the number of languages.
                SelectNumberOfLanquages(ref newDroidNumOfLanguages);

                // >Create a new droid in the array's free spot.
                droidsArray[_freeSpot] = new ProtocolDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidNumOfLanguages);
                break;

            case UTILITY_MC:
            case JANITOR_MC:
            case ASTROMECH_MC:
                bool newDroidToolBox            = false; // >If the droid has a toolbox.
                bool newDroidComputerConnection = false; // >If the droid has a computer connection.
                bool newDroidArm = false;                // >If the droid has and newDroidArm.

                // >set if it has a tool box.
                SelectToolBoxBool(ref newDroidToolBox);
                // >Set if it has a computer connection.
                SelectComputerConnectionBool(ref newDroidComputerConnection);
                // >Set if it has an arm.
                SelectArmBool(ref newDroidArm);

                if (modelChoice == UTILITY_MC)
                {
                    // >Create a new droid in the array's free spot.
                    droidsArray[_freeSpot] = new UtilityDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm);
                }
                else
                {
                    switch (modelChoice)
                    {
                    case JANITOR_MC:
                        bool newDroidTrashCompactor = false; // >If the droid has a trash compactor.
                        bool newDroidVacuum         = false; // >If the droid has a vacuum.

                        // >Set if it has a trash compactor.
                        SelectTrashCompactorBool(ref newDroidTrashCompactor);
                        // >Set if it has a vacuum.
                        SelectVacuumBool(ref newDroidVacuum);

                        // >Create a new droid in the array's free spot.
                        droidsArray[_freeSpot] = new JanitorDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm, newDroidTrashCompactor, newDroidVacuum);
                        break;

                    case ASTROMECH_MC:
                        bool newDroidFireExtinquisher = false; // >If the droid has a FireExtinquisher.
                        int  newDroidNumberOfShips    = 0;     // >The number of ships the droid has worked on.

                        // >Set if it has a FireExtinquisher.
                        SelectFireExtinquisherBool(ref newDroidFireExtinquisher);

                        // >Set the number of ships worked on.
                        SelectNumberOfShips(ref newDroidNumberOfShips);

                        // >Create a new droid in the array's free spot.
                        droidsArray[_freeSpot] = new AstromechDroid(newDroidModel, newDroidMaterial, newDroidColor, newDroidToolBox, newDroidComputerConnection, newDroidArm, newDroidFireExtinquisher, newDroidNumberOfShips);
                        break;
                    }
                }
                break;
            }
            // >Inform the user that the addition was successful.
            UserInterface.WriteToScreen("");
            UserInterface.WriteToScreen("-- The droid has been added to the list --");
            UserInterface.WriteToScreen("");

            // >Change the free spot.
            _freeSpot++;
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public Droid InputDroid()
        {
            string material;
            string model;
            string color;

            Console.WriteLine("Please Select a material the droid is made from" + Environment.NewLine +
                              "1.  Aluminum" + Environment.NewLine +
                              " 2.  Steel" + Environment.NewLine +
                              "3.  Titanium" + Environment.NewLine);
            switch (Console.ReadLine())
            {
            case "1":
                material = "Aluminum";
                break;

            case "2":
                material = "Steel";
                break;

            case "3":
                material = "Titanium";
                break;

            default:
                Console.WriteLine("You did not select a valid option.  Please try again");
                return(null);
            }

            Console.WriteLine("Please enter the color of the droid" + Environment.NewLine);

            color = Console.ReadLine();

            Console.WriteLine("Please select the kind of droid you are logging in" + Environment.NewLine +
                              "1.  Protocol Droid" + Environment.NewLine +
                              "2.  Utility Droid" + Environment.NewLine +
                              "3.  Janitorial Droid" + Environment.NewLine +
                              "4.  Astromech Droid" + Environment.NewLine);
            switch (Console.ReadLine())
            {
            case "1":
                model = "Protocol Droid";
                ProtocolDroid protocolDroid = inputProtocolDroid(material, color, model);
                return(protocolDroid);

            case "2":
                model = "Utility Droid";
                UtilityDroid utilityDroid = inputUtilityDroid(material, color, model);
                return(utilityDroid);

            case "3":
                model = "Janitorial Droid";
                JanitorialDroid janitorialDroid = inputJanitorialDroid(material, color, model);
                return(janitorialDroid);

            case "4":
                model = "Astromech Droid";
                AstromechDroids astromechDroid = inputAstromechDroid(material, color, model);
                return(astromechDroid);

            default:
                Console.WriteLine("I'm sorry, you did not enter a valid entry.  Please try again");
                return(null);
            }
        }
Exemplo n.º 9
0
 //method used for adding a Utilty droid
 public void AddUtilityDroid()
 {
     model = "Utility";                                                                                      //model is named Utility
     material = userInterface.GetDroidMaterial();                                                            //user interface asks user which material to pick from
     color = userInterface.GetDroidColor();                                                                  //user interface asks user which color to pick from
     toolbox = userInterface.GetToolbox();                                                                   //user interface asks user if they want a toolbox for their droid
     computerConnection = userInterface.GetCompConnection();                                                 //user interface asks user if they want a computer connection for their droid
     arm = userInterface.GetArm();                                                                           //user interface asks user if they want an extra arm for their droid
     droids[positionInArray] = new UtilityDroid(material, model, color, toolbox, computerConnection, arm);   //final droid is added to the array
     totalCost = droids[positionInArray].CalculateTotalCost();                                               //total cost is determined based on droid type
     Console.WriteLine(Environment.NewLine + "Final Specs:" +                                                //droid specs are printed to the console for the user to see
         Environment.NewLine + droids[positionInArray] + " " + totalCost.ToString("C") +
         Environment.NewLine);
     positionInArray++;                                                                                      //array index is changed so the recently added droid will not be overwritten
 }