コード例 #1
0
 public void UpdatePrice(Preis newPrice)
 {
     if (newPrice.Amount < 0)
     {
         throw new ArgumentException("Preis muss positiv sein.", nameof(newPrice));
     }
     m_preis = newPrice;
 }
コード例 #2
0
 public void UpdatePrice(decimal newPrice, Waehrung waehrung)
 {
     if (newPrice < 0)
     {
         throw new ArgumentException("Preis muss positiv sein.", nameof(newPrice));
     }
     m_preis = new Preis(newPrice, waehrung);
 }
コード例 #3
0
ファイル: Preis.cs プロジェクト: MichaelObszynski/oom
 private static bool BinaryOp(Preis x, Preis y, Func <decimal, decimal, bool> op)
 {
     if (object.ReferenceEquals(x, null) || object.ReferenceEquals(y, null))
     {
         throw new ArgumentNullException();
     }
     if (x.Unit == y.Unit)
     {
         return(op(x.Amount, y.Amount));
     }
     return(op(x.Amount, y.ConvertTo(x.Unit).Amount));
 }
コード例 #4
0
        public Reifen(string produzent, string modell, Preis price)
        {
            if (string.IsNullOrWhiteSpace(produzent))
            {
                throw new ArgumentException("Bitte Produzenten angeben.", nameof(produzent));
            }
            if (string.IsNullOrWhiteSpace(modell))
            {
                throw new ArgumentException("Bitte Modell angeben.", nameof(modell));
            }

            Produzent = produzent;
            Modell    = modell;
            UpdatePrice(price.Amount, price.Unit);
        }