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; } } }
static void Main(string[] args) { // Create class instances UserInterface ui = new UserInterface(); //Array IDroid[] droidList = new IDroid[20]; DroidCollection droidCollect = new DroidCollection(); int length = 0; string output = ""; //I dont think I needed this, but I was getting some weird formatting issues intially Console.BufferHeight = 1000; //Header (cause console programs are boring) ui.Output("************************************************************" + Environment.NewLine + "********* CIS237 *********" + Environment.NewLine + "******** Assignment #3 ********" + Environment.NewLine + "******* Jawa Inventory Managment *******" + Environment.NewLine + "************************************************************" + Environment.NewLine); //Return tag MenuReturn: int choice = ui.GetMainInput(); //Keep running menu untill user exits while (choice != 3) { //****************************************** //Print option //****************************************** if (choice == 1) { Console.Clear(); foreach (IDroid droid in droidList) { if (droid != null) { output += droid.ToString(); } } Console.WriteLine(output); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); Console.Clear(); goto MenuReturn; } //**************************************** //Add Droid Option //**************************************** if (choice == 2) { Console.Clear(); droidCollect.AddDroid(droidList, length); length++; Console.WriteLine(""); Console.WriteLine("Complete! Press any key to continue..."); Console.ReadKey(); Console.Clear(); goto MenuReturn; } Environment.Exit(0); } }
/// <summary> /// Handles user selection of droid Type. /// </summary> private void DroidTypeSelection() { UserInterface.Menus.DisplayTypeSelectionMenu(); userInputString = UserInterface.GetUserInput(); switch (userInputString) { case "1": PurchaseProtocol(); // After user selects values for droid, actually create it, add it to the collection, and calculate the various associated prices. if (menusBool) { UserInterface.ClearDisplayLine(); IDroid aDroid = new Droid_Protocol(selectedMaterialString, selectedModelString, selectedColorString, selectedLanguageInt); droidCollection.AddDroid(aDroid); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateFeatures(); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateTotalCost(); } break; case "2": PurchaseUtility(); // After user selects values for droid, actually create it, add it to the collection, and calculate the various associated prices. if (menusBool) { UserInterface.ClearDisplayLine(); IDroid aDroid = new Droid_Utility(selectedMaterialString, selectedModelString, selectedColorString, toolBoxBool, computerConnectionBool, armBool); droidCollection.AddDroid(aDroid); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateFeatures(); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateTotalCost(); } break; case "3": PurchaseJanitor(); // After user selects values for droid, actually create it, add it to the collection, and calculate the various associated prices. if (menusBool) { UserInterface.ClearDisplayLine(); IDroid aDroid = new Droid_Janitor(selectedMaterialString, selectedModelString, selectedColorString, toolBoxBool, computerConnectionBool, armBool, trashCompactorBool, vacuumBool); droidCollection.AddDroid(aDroid); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateFeatures(); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateTotalCost(); } break; case "4": PurchaseAstromech(); // After user selects values for droid, actually create it, add it to the collection, and calculate the various associated prices. if (menusBool) { UserInterface.ClearDisplayLine(); IDroid aDroid = new Droid_Astromech(selectedMaterialString, selectedModelString, selectedColorString, toolBoxBool, computerConnectionBool, armBool, fireExtinguisherBool, selectedNumberOfShipsInt); droidCollection.AddDroid(aDroid); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateFeatures(); droidCollection.DroidList[droidCollection.DroidListSize - 1].CalculateTotalCost(); } break; case "esc": UserInterface.ClearDisplayLine(); break; default: UserInterface.DisplayError("Invalid selection."); DroidTypeSelection(); break; } }