Beispiel #1
0
        private void Shopping(string buying)
        {
            string[] buyingArr = buying
                                 .Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
            string name    = buyingArr[0].Trim();
            string product = buyingArr[1].Trim();

            if (name == "" || product == "")
            {
                Console.WriteLine("Name cannot be empty");
                throw new ArgumentException();
            }

            Product productToBuy = products.Find(x => x.Name == product);
            Person  person       = people.Find(x => x.Name == name);

            person.BuyingProduct(productToBuy);
        }