//*************************END ADD DROID METHOD***************************// //*************************ADD PROTOCOL METHOD*****************************// public void AddProtocol() { DroidOptions("Protocol"); //ADD NEW PROTOCOL TO DROID COLLECTION AND DISPLAY CONFIRMATION Console.WriteLine(); Droid newProtocol = new Protocol(materailSelectionString, "Protocol", colorSelectionString, numLangauges); droidCollection.AddNewDroid(newProtocol); newProtocol.CalculateBaseCost(); newProtocol.CalculateTotalCost(); totalCost += newProtocol.totalCost; Console.WriteLine(newProtocol + " has been added to droid collection.\n"); }
//CONSTRUCTOR THAT ADDS A NEW PROTOCOL DROID public void addDroid(string ModelType, string MaterialType, string PaintColor, int LanguageCount) { Protocol newDroid = new Protocol(ModelType, MaterialType, PaintColor, LanguageCount); droidCollection.Add(newDroid); }
// 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); }
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) { Protocol protocol = new Protocol("Titanium","New","Black",1200); protocol.ToString(); }
//Different methods for different model types. public void AddProtocol(string Model, string Material, string Color, int NumberOfLanguages) { droidArray[counter] = new Protocol(Material, Model, Color, NumberOfLanguages); counter++; }
//Add new Protocol Droid to the Droid Collection and increase the length variable. public void NewDroid(String model, String material, String color, Int32 numberLanguages) { droids[droidsLength] = new Protocol(model, material, color, numberLanguages); droidsLength++; }