public static void GetCarCount(string brand) { List <CarOwner> carOwnersList = CarOwner.GetInfoFromFile(@"K:\Epam C Sharp dot net\textFile2.txt"); List <string> dataList = new List <string>(); int count = 0; foreach (CarOwner carOwner in carOwnersList) { if (carOwner.GetBrand().Equals(brand)) { count++; } } Console.WriteLine("The cars count:"); Console.WriteLine(brand + " " + count + " car(s)"); if (dataList.Count == 0) { Console.WriteLine("There isn't information with such data"); } }
public static void GetInfoByBrand(string brand) { List <CarOwner> carOwnersList = CarOwner.GetInfoFromFile(@"K:\Epam C Sharp dot net\textFile2.txt"); List <string> dataList = new List <string>(); foreach (CarOwner carOwner in carOwnersList) { if (carOwner.GetBrand().Equals(brand)) { string data = carOwner.GetName() + " " + carOwner.GetCarNumber(); dataList.Add(data); } } Console.WriteLine("Car owners name and car number:"); foreach (string data in dataList) { Console.WriteLine(data); } if (dataList.Count == 0) { Console.WriteLine("There isn't information with such data"); } }
public static void GetInfoByRegionNumber(string region) { List <CarOwner> carOwnersList = CarOwner.GetInfoFromFile(@"K:\Epam C Sharp dot net\textFile2.txt"); List <string> dataList = new List <string>(); foreach (CarOwner carOwner in carOwnersList) { string regionNumber = carOwner.GetCarNumber().Substring(carOwner.GetCarNumber().Length - 2); if (regionNumber.Equals(region)) { string data = carOwner.GetName(); dataList.Add(data); } } Console.WriteLine("Car owners name:"); foreach (string data in dataList) { Console.WriteLine(data); } if (dataList.Count == 0) { Console.WriteLine("There isn't information with such data"); } }