static Organization ReadElement() { PrintMenuForElementsSearch(); Organization elem = new Organization(); int userChoice = ReadInt(1, 5, "=== Выберите тип элемента ==="); switch (userChoice) { case 1: // Type Organization Organization o = new Organization(); o.Input(); elem = o; break; case 2: // Type Factory Factory f = new Factory(); f.Input(); elem = f; break; case 3: // Type InsuranceCompany InsuranceCompany i = new InsuranceCompany(); i.Input(); elem = i; break; case 4: // Type Library Library l = new Library(); l.Input(); elem = l; break; case 5: // Type ShipbuildingCompany ShipbuildingCompany s = new ShipbuildingCompany(); s.Input(); elem = s; break; } return(elem); }
static void AddElementList(ref List <Organization> listOrganizations) { PrintMenuForElements(); int userChoice = ReadInt(1, 5, "=== Выберите тип элемента ==="); switch (userChoice) { case 1: // Type Organization Organization o = new Organization(); o.Input(); listOrganizations.Add(o); break; case 2: // Type Factory Factory f = new Factory(); f.Input(); listOrganizations.Add(f); break; case 3: // Type InsuranceCompany InsuranceCompany i = new InsuranceCompany(); i.Input(); listOrganizations.Add(i); break; case 4: // Type Library Library l = new Library(); l.Input(); listOrganizations.Add(l); break; case 5: // Type ShipbuildingCompany ShipbuildingCompany s = new ShipbuildingCompany(); s.Input(); listOrganizations.Add(s); break; } }
static void AddElement(ref SortedList sortedList) { PrintMenuForElements(); int userChoice = ReadInt(1, 5, "=== Выберите тип элемента ==="); switch (userChoice) { case 1: // Type Organization Organization o = new Organization(); o.Input(); if (sortedList.Contains(o.Name)) { Console.WriteLine("=== Такой элемент уже есть ==="); } else { sortedList.Add(o.Name, o); } break; case 2: // Type Factory Factory f = new Factory(); f.Input(); if (sortedList.Contains(f.Name)) { Console.WriteLine("=== Такой элемент уже есть ==="); } else { sortedList.Add(f.Name, f); } break; case 3: // Type InsuranceCompany InsuranceCompany i = new InsuranceCompany(); i.Input(); if (sortedList.Contains(i.Name)) { Console.WriteLine("=== Такой элемент уже есть ==="); } else { sortedList.Add(i.Name, i); } break; case 4: // Type Library Library l = new Library(); l.Input(); if (sortedList.Contains(l.Name)) { Console.WriteLine("=== Такой элемент уже есть ==="); } else { sortedList.Add(l.Name, l); } break; case 5: // Type ShipbuildingCompany ShipbuildingCompany s = new ShipbuildingCompany(); s.Input(); if (sortedList.Contains(s.Name)) { Console.WriteLine("=== Такой элемент уже есть ==="); } else { sortedList.Add(s.Name, s); } break; } }