public static void Main() { persons = new List <Person>(); products = new List <Product>(); string[] peoplesAndMoney = Console.ReadLine() .Split(";", StringSplitOptions.RemoveEmptyEntries); AddPersonToList(peoplesAndMoney); string[] propductsAndCosts = Console.ReadLine() .Split(";", StringSplitOptions.RemoveEmptyEntries); AddProductToList(propductsAndCosts); while (true) { string[] inputArgs = Console.ReadLine().Split(); if (inputArgs[0] == "END") { break; } string peopleName = inputArgs[0]; string productToBuy = inputArgs[1]; Person currentPerson = persons.FirstOrDefault(x => x.Name == peopleName); Product currentProduct = products.FirstOrDefault(x => x.Name == productToBuy); currentPerson.AddProductToList(currentProduct); } foreach (var person in persons) { int productCount = person.Products.Count; if (productCount > 0) { Console.WriteLine($"{person.Name} - {string.Join(", ", person.Products.Select(x => $"{x.Name}"))}"); } else { Console.WriteLine($"{person.Name} - Nothing bought"); } } }