示例#1
0
        private static void BuyProducts(List <Person> people, List <Product> products)
        {
            string command;

            while ((command = Console.ReadLine()) != "END")
            {
                string[] token       = command.Split();
                string   personName  = token[0];
                string   productName = token[1];
                Person   person      = people.First(p => p.Name == personName);
                Product  product     = products.First(p => p.Name == productName);

                string output = person.TryBuyProduct(product);
                Console.WriteLine(output);
            }
        }