Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Klasa 1
- namespace ShoppingCart
- {
- public class Product
- {
- public string Name { get; set; }
- public string Category { get; set; }
- public float Price { get; set; }
- public Product(string name, string cat, float price)
- {
- Name = name;
- Category = cat;
- Price = price;
- }
- public override string ToString()
- {return Name;}}}
- //Klasa 2
- public class ProductItem
- { public Product Product { get; set; }
- public int Quantity { get; set; }
- public ProductItem(Product p, int q)
- {
- Product = p;
- Quantity = q;
- }
- public override string ToString()
- {
- return String.Format("{0} {1:0.0} x {2:0.0} = {3:0.0}", Product.Name, Quantity, Product.Price, Quantity * Product.Price); }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement