public override string ToString()
 {
     if (BagOfProducts.Count == 0)
     {
         return($"{this.Name} - Nothing bought");
     }
     else
     {
         return($"{this.Name} - {string.Join(", ", BagOfProducts.Select(n => n.Name).ToList())}");
     }
 }
Exemplo n.º 2
0
    public void Buy(Product product)
    {
        if (Money >= product.Price)
        {
            BagOfProducts.Add(product);

            Money -= product.Price;

            Console.WriteLine($"{Name} bought {product.Name}");
        }
        else
        {
            Console.WriteLine($"{Name} can't afford {product.Name}");
        }
    }