Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. //Klasa 1
  2. namespace ShoppingCart
  3. {
  4.     public class Product
  5.     {
  6.         public string Name { get; set; }
  7.         public string Category { get; set; }
  8.         public float Price { get; set; }
  9.  
  10.         public Product(string name, string cat, float price)
  11.         {
  12.             Name = name;
  13.             Category = cat;
  14.             Price = price;
  15.         }
  16.  
  17.         public override string ToString()
  18.         {return Name;}}}
  19. //Klasa 2
  20.         public class ProductItem
  21.     {   public Product Product { get; set; }
  22.         public int Quantity { get; set; }
  23.  
  24.         public ProductItem(Product p, int q)
  25.         {
  26.             Product = p;
  27.             Quantity = q;
  28.         }
  29.  
  30.         public override string ToString()
  31.         {
  32.             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