social1986

Untitled

Feb 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. public class Product
  2. {
  3.     private string name;
  4.     private decimal cost;
  5.  
  6.     public Product(string name, decimal cost)
  7.     {
  8.         this.Name = name;
  9.         this.Cost = cost;
  10.     }
  11.  
  12.     public decimal Cost
  13.     {
  14.         get { return cost; }
  15.         set
  16.         {
  17.             Validator.ValidatingMoney(value);
  18.             cost = value;
  19.         }
  20.     }
  21.  
  22.     public string Name
  23.     {
  24.         get { return name; }
  25.         set
  26.         {
  27.             Validator.ValidatingName(value);
  28.             name = value;
  29.         }
  30.     }
  31.  
  32.     public override string ToString()
  33.     {
  34.         return name;
  35.     }
  36. }
Add Comment
Please, Sign In to add comment