static void Main(string[] args)
        {
            //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);

            //START PROGRAM PROCESSES
            UserInterface userInterface = new UserInterface();
        }
        static void Main(string[] args)
        {
            //instance of droid list object created
            List<Droid> droid = new List<Droid>();

            //instance of user interface
            UserInterface ui = new UserInterface();

            //instance of droid collection
            DroidCollection droidCollection = new DroidCollection();

            //display Main Menu of program
            ui.DisplayMainMenu(droid, droidCollection);
        }
        static void Main(string[] args)
        {
            DroidCollector droidCollector = new DroidCollector();
            UserInterface UI = new UserInterface(droidCollector);
            int userInput;

            do
            {   //Menu loop
                userInput = UI.ShowMenu();

                switch (userInput)
                {
                    case 1:
                        UI.PrintDroidList();
                        break;
                    case 2:
                        UI.AddDroid();
            ;                       break;
                    default:
                        break;
                }

            } while (userInput != 3);
        }
        private static void AddDroid(DroidCollecion droidCollection, UserInterface userInterface)
        {
            //istantiate variables
            DroidCollecion dc = droidCollection;
            UserInterface ui = userInterface;
            IDroid droid = null;
            string droidMaterial;
            string droidColor;
            string droidType;
            int droidNumberLanguages;
            bool droidToolBox;
            bool droidComputerConnection;
            bool droidArm;
            bool droidFireExtingusher;
            int droidNumberShips;
            bool droidTrashCompactor;
            bool droidVacuum;

            try     //catch incorrect entries
            {
                ui.DroidMaterial();
                droidMaterial = ui.ReadLine();
                ui.DroidColor();
                droidColor = ui.ReadLine();
                ui.DroidType();
                droidType = ui.ReadLine();

                if (droidType == "Astromech") //astromech path
                {
                    //utility variables
                    ui.ToolBoxAsk();
                    droidToolBox = Convert.ToBoolean(ui.ReadLine());
                    ui.ComputerConnectionAsk();
                    droidComputerConnection = Convert.ToBoolean(ui.ReadLine());
                    ui.ArmAsk();
                    droidArm = Convert.ToBoolean(ui.ReadLine());
                    //Astromech variables
                    ui.FireExtinguisher();
                    droidFireExtingusher = Convert.ToBoolean(ui.ReadLine());
                    ui.NumberShips();
                    droidNumberShips = Convert.ToInt32(ui.ReadLine());
                    //create new astromech in the droid variable
                    droid = new Astromech(droidMaterial, droidType, droidColor, droidToolBox, droidComputerConnection, droidArm, droidFireExtingusher, droidNumberShips);
                }
                else if (droidType == "Janitor")  //janitor path
                {
                    //Utitlity variables
                    ui.ToolBoxAsk();
                    droidToolBox = Convert.ToBoolean(ui.ReadLine());
                    ui.ComputerConnectionAsk();
                    droidComputerConnection = Convert.ToBoolean(ui.ReadLine());
                    ui.ArmAsk();
                    droidArm = Convert.ToBoolean(ui.ReadLine());
                    //Janitor variables
                    ui.TrashCompactor();
                    droidTrashCompactor = Convert.ToBoolean(ui.ReadLine());
                    ui.Vacuum();
                    droidVacuum = Convert.ToBoolean(ui.ReadLine());
                    //Create new janitor in the droid variable
                    droid = new Janitor(droidMaterial, droidType, droidColor, droidToolBox, droidComputerConnection, droidArm, droidTrashCompactor, droidVacuum);
                }
                else if (droidType == "Protocol") //protocol path
                {
                    //Protocol variables
                    ui.DroidLanguages();
                    droidNumberLanguages = Convert.ToInt32(ui.ReadLine());
                    //create new Protocol droid in the droid variable
                    droid = new Protocol(droidMaterial, droidType, droidColor, droidNumberLanguages);
                }
                else
                {
                    ui.DroidTypeError();    //output type error message
                }
            }
            catch
            {
                ui.Print("Invalid entry");
            }
            if (droid == null)  //if no droid was made do not add it to the list
            {
                ui.DroidNotAdded();
            }
            else
            {
                //if the droid is made add it to the list
            }
            {
                dc.AddDroid(droid);
                ui.DroidAdded();
            }
        }
        static void Main(string[] args)
        {
            bool exitCondition = false;
            int selectionInt;
            UserInterface ui = new UserInterface();
            DroidCollecion dc = new DroidCollecion();

            while (!exitCondition)  //main program loop
            {
                ui.DisplayMenu();
                selectionInt = 0;
                bool selectionIntRead = false;
                try     //catches letters entered into the console
                {
                    selectionInt = Convert.ToInt32(ui.ReadLine());
                    selectionIntRead = true;
                }
                catch
                {
                    ui.Print(Environment.NewLine + "Enter a number Please." + Environment.NewLine);
                }

                if (selectionIntRead)
                {
                    switch (selectionInt)
                    {
                        case 0:     //Exit program
                            exitCondition = true;
                            break;

                        case 1:     //Add droid
                            AddDroid(dc, ui);
                            break;

                        case 2:     //print droid list
                            ui.Print(dc.PrintArray());
                            break;

                        default:    //catches numbers not used
                            ui.ErrorMessage2();
                            break;
                    }
                }

            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            //***************************************
            //Variables
            //***************************************

            string    materialTest        = "plastic";
            string    DroidTypeTest       = "Protocol";
            string    colorTest           = "red";
            int       numberLanguagesTest = 1000;
            int       menuChoice;
            const int DROID_COLLECTION_SIZE = 1000;

            //Create a single DroidCollection to be used for the entire program
            DroidCollection droidCollection = new DroidCollection(DROID_COLLECTION_SIZE);

            //Create a single UserInterface to be used for the entire program
            UserInterface ui = new UserInterface();

            //Create the console to be used
            ui.StartUserInterface();

            //Create the LoadMenu and load the user choice
            menuChoice = ui.LoadMenu();

            // Either user wants to load a droid list or  not
            switch (menuChoice)
            {
            case 1:
                droidCollection.AddNewItem(materialTest, DroidTypeTest, colorTest, numberLanguagesTest);
                droidCollection.AddNewItem("steele", "Utility", "white", true, true, true);
                droidCollection.AddNewItem("Plass-Steele", "Janitor", "blue", true, true, false, true, true);
                droidCollection.AddNewItem("Nevo-Titanium", "Astromech", "orange", true, false, true, true, 10);

                ui.ListLoadedMessage();

                break;

            case 2:    // If droidCollection was not created need to start by adding a droid.
                ui.AddDroidSequence(droidCollection);
                break;
            }

            //Continue to loop until the user chooses 4 which is to exit.
            while (menuChoice != 4)
            {
                menuChoice = ui.MainMenu();
                switch (menuChoice)
                {
                case 1:    //Print out the droid list
                    ui.PrintDroidList(droidCollection.GetListOfAllDroids());
                    break;

                case 2:    //Add a new droid to the DroidCollection
                    ui.AddDroidSequence(droidCollection);
                    break;

                case 3:    //Delete a droid from the DroidCollection
                    //Make sure the DroidCollection has Droids in them
                    if (droidCollection.NumberOfDroidsInList > 0)
                    {
                        ui.PrintDroidList(droidCollection.GetListOfAllDroids());
                        ui.DeleteDroid(droidCollection);
                    }
                    else
                    {
                        ui.NoDroidsInListMessage();
                    }

                    break;

                default:    //Exit the program
                    ui.ExitMessage();
                    break;
                }
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            //Variables to be used throughout
            String model = String.Empty;
            String material = String.Empty;
            String color = String.Empty;
            Boolean toolbox = false;
            Boolean computerConnection = false;
            Boolean arm = false;
            Boolean trashCompactor = false;
            Boolean vacuum = false;
            Boolean fireExtinquisher = false;
            Int32 numberShips = 0;

            //Constant size for the Droid Collection
            const Int32 DROID_COLLECTION_SIZE = 100;

            //Create an instance of the UserInterface and DroidCollection classes
            UserInterface userInterface = new UserInterface();
            DroidCollection droidCollection = new DroidCollection(DROID_COLLECTION_SIZE);

            //Prompt for user input.
            Int32 choice1 = userInterface.FirstMenu();
            Int32 type;

            //While the user has not chosen to exit the program.
            while (choice1 != 3)
            {
                //If the user has chosen to ADD a Droid.
                if (choice1 == 1)
                {
                    type = userInterface.BeginBuild();
                    material = userInterface.MaterialOption();
                    color = userInterface.ColorOption();

                    switch (type)
                    {
                        case 1:
                            {
                                model = "Protocol";
                                Int32 languages = userInterface.ProtocolNumberLanguages();
                                droidCollection.NewDroid(model, material, color, languages);
                                userInterface.DroidAddSuccess();
                                break;
                            }
                        case 2:
                            {
                                model = "Utility";
                                toolbox = userInterface.UtilityToolbox();
                                computerConnection = userInterface.UtilityComputerConnection();
                                arm = userInterface.UtilityArm();
                                droidCollection.NewDroid(model, material, color, toolbox, computerConnection, arm);
                                userInterface.DroidAddSuccess();
                                break;
                            }
                        case 3:
                            {
                                model = "Janitor";
                                toolbox = userInterface.UtilityToolbox();
                                computerConnection = userInterface.UtilityComputerConnection();
                                arm = userInterface.UtilityArm();
                                trashCompactor = userInterface.JanitorTrashCompactor();
                                vacuum = userInterface.JanitorVacuum();
                                droidCollection.NewDroid(model, material, color, toolbox, computerConnection, arm, trashCompactor, vacuum);
                                userInterface.DroidAddSuccess();
                                break;
                            }
                        case 4:
                            {
                                model = "Astromech";
                                toolbox = userInterface.UtilityToolbox();
                                computerConnection = userInterface.UtilityComputerConnection();
                                arm = userInterface.UtilityArm();
                                fireExtinquisher = userInterface.AstromechFireExtinquisher();
                                numberShips = userInterface.AstromechNumberShips();
                                droidCollection.NewDroid(model, material, color, toolbox, computerConnection, arm, fireExtinquisher, numberShips);
                                userInterface.DroidAddSuccess();
                                break;
                            }
                    }
                }
                //If the user has chosen to PRINT the Droid list.
                if (choice1 == 2)
                {
                    string[] allDroids = droidCollection.AquireAllDroids();
                    if (allDroids.Length > 0)
                    {
                        userInterface.DisplayAllDroids(allDroids);
                    }
                    else
                    {
                        userInterface.DisplayNoDroidsError();
                    }

                }
                //Prompt the user to make a choice from the first menu again.
                choice1 = userInterface.FirstMenu();
            }
        }