private List <Mashine> GenerMashine(out string message) { List <Mashine> Mashines = new List <Mashine>(); for (int i = 0; i < 5; i++) { Mashine mashine = new Mashine(); mashine.GodVupuska = DateTime.Now.AddMonths((rand.Next(10, 200) * -1)); mashine.GosNomer = rand.Next(1000, 9999); mashine.Model = "Model" + rand.Next(1, 10); mashine.TypeMasine = (TypeMasine)rand.Next(1, 3); mashine.Components = GenerComponents(out message); Mashines.Add(mashine); } message = "Mashines complete"; return(Mashines); }
static void Main(string[] args) { Generator generator = new Generator(); List <Project> projects = null; string message; if (!generator.Gener(ref projects, out message)) { Console.WriteLine(message); return; } foreach (Project item in projects) { item.PrintInfo(); } Console.WriteLine("Выберите проект: "); foreach (var item in projects) { Console.WriteLine(" - " + item.NameProject); } Project temp = null; do { //спрашиваем Console.Write("-> "); string name = Console.ReadLine(); //ищем temp = projects.FirstOrDefault(o => o.NameProject.ToLower() == name.ToLower()); //регистронезависимые //проверяем if (temp != null) { break; } //если не нашли Console.WriteLine("Проект не найден!"); }//пока не нашли while (temp == null); Console.WriteLine("Выберите критерии поиска : 1 - гаражный номер, 2 - модель"); int choice = 0; do { Console.Write("-> "); Int32.TryParse(Console.ReadLine(), out choice); } while (choice != 1 && choice != 2); int gosNomer = 0; string modelMasine = ""; Service service = new Service(); Mashine findeMashine = null; switch (choice) { case 1: { Console.Write("Введите гос номер машины -> "); Int32.TryParse(Console.ReadLine(), out gosNomer); findeMashine = service.Search(temp, gosNomer); } break; case 2: { Console.Write("Введите модель машины -> "); findeMashine = service.Search(temp, Console.ReadLine()); } break; } if (findeMashine == null) { Console.WriteLine("Машина не найдена"); } else { findeMashine.PrintInfo(); } // --------------------------------------------------- }