public Product(final ProductType productType, final PriceList priceList) throws ProductException, PriceListException, NoPriceException { if (productType == null) { throw new ProductException("Product type cannot be null"); } if (!priceList.isPriceSet(productType)) { throw new NoPriceException(); } this.productType = productType; }
@Override public String toString() { String result = getName() + " własciciel " + owner.getName(); if (container.isEmpty()) { result += " -- pusto"; } result += "\n"; for (Bouquet b : container) { result += b.getName() + ", kolor: " + b.getColor() + ", ilość " + b.getCount() + ", cena " + PriceList.getInstance().getPrice(b.getName()) + "\n"; } return result; }
void scan(String itemName) { total += priceList.getPrice(itemName); }
@Test(expected = PriceNotFound.class) public void reportsPriceNotFound() throws Exception { priceList.findPrice("XXX"); }
@Test public void findsAPrice() { assertEquals(111, priceList.findPrice("A")); }