private static void DisplayAddAtty(List <Atomizer> atomizers) { int intVal; Atomizer atomizer = new Atomizer(); DisplayHeader("Add Atomizer."); Console.Write("Enter Brand name:"); atomizer.Brand = Console.ReadLine().ToUpper(); Console.Write("Enter Model:"); atomizer.Model = Console.ReadLine().ToUpper(); Console.Write("Enter Atomizer Type:"); Enum.TryParse(Console.ReadLine().Replace(" ", "_"), out Atomizer.BuildTypes buildType); atomizer.Type = buildType; atomizer.DisplayDeckTypes(); Console.WriteLine("Enter Deck Type:"); Enum.TryParse(Console.ReadLine().Replace(" ", "_").ToUpper(), out Atomizer.DeckTypes deckType); atomizer.Deck = deckType; Console.Write("How many coils?"); int.TryParse(Console.ReadLine(), out intVal); atomizer.CoilCount = intVal; atomizers.Add(atomizer); Console.WriteLine("The atomizer {0} has been added to the inventory.", atomizer.Model); DisplayContinuePrompt(); //change test 2 }
static List <Atomizer> DisplayOpenAtty(string dataPath) { const char delineator = ','; List <string> attyStringList = new List <string>(); Atomizer tempAtty = new Atomizer(); List <Atomizer> tempAttys = new List <Atomizer>(); // // read each line and put it into an array and convert the array to a list // try { attyStringList = File.ReadAllLines(dataPath).ToList(); } catch (Exception) // throw any exception up to the calling method { throw; } // // create character object for each line of data read and fill in the property values // foreach (string modString in attyStringList) { tempAtty = new Atomizer(); // use the Split method and the delineator on the array to separate each property into an array of properties string[] properties = modString.Split(delineator); tempAtty.Brand = properties[0]; tempAtty.Model = properties[1]; tempAtty.Deck = (Atomizer.DeckTypes)Enum.Parse(typeof(Atomizer.DeckTypes), properties[2]); tempAtty.Type = (Atomizer.BuildTypes)Enum.Parse(typeof(Atomizer.BuildTypes), properties[3]); tempAtty.CoilCount = Convert.ToInt32(properties[4]); tempAtty.Using = Convert.ToBoolean(properties[5]); tempAttys.Add(tempAtty); } Console.WriteLine("Atomizer List loaded from file, {0}.", dataPath); DisplayContinuePrompt(); return(tempAttys); }