public Coin(int value) { if (value <= 0) { throw new Exception("The coin value must be greater than 0."); } this.value = new Cents(value); }
public Coin(Cents value) { if (value.Value <= 0) { throw new Exception("The coin value must be greater than 0. The argument passed was: " + value); } this.value = value; }
private void notifyCostChanged(Cents oldCost, Cents newCost) { if (this.CostChanged != null) { this.CostChanged(this, new CostChangedEventArgs() { OldCost = oldCost, NewCost = newCost }); } }
/** * Basic constructor. * * @param name * The name of the product kind. Cannot be null. * @param cost * The cost of the product kind. Cannot be non-positive. */ public ProductKind(String name, Cents cost) { if (name == null) { throw new ArgumentException("The name cannot be null"); } if (cost.Value <= 0) { throw new ArgumentOutOfRangeException("The cost cannot be non-positive"); } this.Name = name; this.Cost = cost; }