public CompactDisk(string bandname, string diskname, string asin, myPrice price) { if (string.IsNullOrWhiteSpace (bandname)) throw new ArgumentException ("You've to add a bandname to CDs."); if (string.IsNullOrWhiteSpace (diskname)) throw new ArgumentException ("You've to add the title of the disk."); if (string.IsNullOrWhiteSpace (asin)) throw new ArgumentException ("ASIN mustn't be empty."); Bandname = bandname; Diskname = diskname; ASIN = asin; UpdatePrice (price.Amount,price.Unit); }
public Vinyl(string bandname, string diskname, int speed ,int size, myPrice price) { if (string.IsNullOrWhiteSpace (bandname)) throw new ArgumentException ("You've to add a bandname to Vinyls."); if (string.IsNullOrWhiteSpace (diskname)) throw new ArgumentException ("You've to add the title of the disk."); if (speed!=33 && speed !=45) throw new ArgumentException ("There are only two speeds available for vinyl discs [33 & 45 rpm]."); if (size!=30 && size !=15 && size!=25) throw new ArgumentException ("There are only three sizes available for vinyl discs [15,25 & 30 cm]."); Bandname = bandname; Diskname = diskname; Speed = speed; Size = size; UpdatePrice (price.Amount,price.Unit); }
public void CanCreatePrice() { var x = new myPrice(1, Currency.EUR); Assert.IsTrue(x.Amount == 1); Assert.IsTrue(x.Unit == Currency.EUR); }
public void UpdatePrice(decimal newprice, Currency curr) { if (newprice < 0) throw new ArgumentException ("Price must not be negative."); actualprice = new myPrice(newprice, curr); }