//This method takes user input and returns a List of string arrays //Example input: 1xr 10 10 30 40 enter..... public static List <Material> Input() { Console.WriteLine("Plese input widget spec: "); string line = string.Empty; List <Material> materials = new List <Material>(); while (!(line.Equals("END"))) { int materialCount; string materialType; string[] materialCountAndType; string[] specLine; line = Console.ReadLine(); if (!(line.Equals("END"))) { if (ValidationOfSpace(line)) { specLine = line.Split(' '); if (ValidateFormat(specLine[0])) { materialCountAndType = specLine[0].Split('x'); materialCount = int.Parse(materialCountAndType[0]); materialType = materialCountAndType[1].ToUpper(); materials.Add(MaterialFactory.Create(materialCount, materialType, specLine)); } else { try { Exception e = new Exception(); throw e; } catch (Exception) { MaterialLogger.Log("Wrong input formt!!"); Console.WriteLine("+++++Abort+++++"); Console.ReadKey(); Environment.Exit(1); } } } } else { break; } } return(materials); }
public static void Main(string[] args) { List <Material> matirialSpecification = Input(); if (Validation(matirialSpecification)) { Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine("Bill of Materials"); Console.WriteLine("----------------------------------------------------------------"); Output(matirialSpecification); Console.WriteLine("----------------------------------------------------------------"); } else { MaterialLogger.Log(); Console.WriteLine("+++++Abort+++++"); } Console.ReadKey(); }