Пример #1
0
        static void Main(string[] args)
        {
            UserInterface   userInterface   = new UserInterface();
            DroidCollection droidCollection = new DroidCollection();
            bool            exitBool        = false;

            while (exitBool == false)
            {
                int choice = userInterface.MainMenu();

                switch (choice)
                {
                case 1:
                    Droid inputDroid = userInterface.InputDroid();
                    droidCollection.AddDroid(inputDroid);
                    break;

                case 2:
                    string output = droidCollection.ToString();
                    userInterface.PrintAllOutput(output);
                    break;

                case 3:
                    exitBool = true;
                    break;

                default:
                    userInterface.PrintError();
                    break;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// returns an instance of JanitorDroid based of the prompts
        /// </summary>
        /// <returns></returns>
        public static new Droid CreateDroid()
        {
            bool   toolBoxTmp, computerConnectionTmp, armTmp, vacuumTmp, trashCompactorTmp;
            string material, color;

            Console.WriteLine("Please input the droids material");
            material = Console.ReadLine();

            Console.WriteLine("Please input the droids color");
            color = Console.ReadLine();

            Console.WriteLine("has a toolbox? (y/n)");
            toolBoxTmp = Droid.yesOrNo();

            Console.WriteLine("has a computer connection? (y/n)");
            computerConnectionTmp = Droid.yesOrNo();

            Console.WriteLine("has a arm? (y/n)");
            armTmp = Droid.yesOrNo();

            Console.WriteLine("has a vacuum? (y/n)");
            vacuumTmp = Droid.yesOrNo();

            Console.WriteLine("has a trash compactor? (y/n)");
            trashCompactorTmp = Droid.yesOrNo();

            return(new JanitorDroid(material, color, toolBoxTmp, computerConnectionTmp, armTmp, trashCompactorTmp, vacuumTmp));
        }
 public void AddDroid(Droid addDroid)
 {
     int counter = 0;
     for (counter = 0; counter < droids.Length; counter++)
     {
         if (droids[counter] == null)
         {
             droids[counter] = addDroid;
             return;
         }
     }
 }
        public void AddDroid(Droid addDroid)
        {
            int counter = 0;

            for (counter = 0; counter < droids.Length; counter++)
            {
                if (droids[counter] == null)
                {
                    droids[counter] = addDroid;
                    return;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// returns an instance of AstromechDroid based of the prompts
        /// </summary>
        /// <returns></returns>
        public static new Droid CreateDroid()
        {
            bool   toolBoxTmp, computerConnectionTmp, armTmp, fireExtinquisherTmp;
            string material, color;
            int    shipsSupportedTmp;

            Console.WriteLine("Please input the droids material");
            material = Console.ReadLine();

            Console.WriteLine("Please input the droids color");
            color = Console.ReadLine();

            Console.WriteLine("has a toolbox? (y/n)");
            toolBoxTmp = Droid.yesOrNo();

            Console.WriteLine("has a computer connection? (y/n)");
            computerConnectionTmp = Droid.yesOrNo();

            Console.WriteLine("has a arm? (y/n)");
            armTmp = Droid.yesOrNo();

            Console.WriteLine("has a fireExtinquisher? (y/n)");
            fireExtinquisherTmp = Droid.yesOrNo();

            Console.WriteLine("number of supported ships");
            //prevents bad input
            while (!int.TryParse(Console.ReadLine(), out shipsSupportedTmp))
            {
                //deletes bad input from the console
                int currentLineInt = Console.CursorTop - 1;
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                Console.Write(new string(' ', Console.WindowWidth));
                Console.SetCursorPosition(0, currentLineInt);
            }

            return(new AstromechDroid(material, color, toolBoxTmp, computerConnectionTmp, armTmp, fireExtinquisherTmp, shipsSupportedTmp));
        }
 //***************END METHOD TO CREATE NEW DROID COLLECTION ARRAY***************//
 //*******************METHOD TO ADD NEW DROID TO COLLECTION**************//
 public void AddNewDroid(Droid newDroid)
 {
     droidCollection[droidCollectionLength] = newDroid;
     droidCollectionLength++;
 }
Пример #7
0
 //Add a new item to the collection
 public void AddNewItem(string material, string model, string color)
 {
     //Add a new WineItem to the collection. Increase the Length variable.
     droidItems[droidItemsLength] = new Droid(material, model, color);
     droidItemsLength++;
 }
Пример #8
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);
        }
Пример #9
0
 // adds a new droid to droid collections
 public void Add(Droid NDroid)
 {
     DCollection[DCLength] = NDroid;
     //increment length
     DCLength++;
 }