import java.io.IOException; import java.io.Writer; /** * Simple representation of a product * * @author (your name) * @version (a version number or a date) */ public class Product { private final int productNo; private TaxCategory taxCategory; private String name; private double priceExTax; private static int nextProductNo = 0; public Product(String name, double priceExTax, TaxCategory taxCategory) { productNo = nextProductNo++; this.name = name; this.priceExTax = priceExTax; this.taxCategory = taxCategory; if (taxCategory == null) throw new IllegalArgumentException("Notnull!!!!!"); } public int getProductNo() { return productNo; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getPriceExTax() { return priceExTax; } public void setPriceExTax(double priceExTax) { this.priceExTax = priceExTax; } public double getPriceWithTax() { return taxCategory.getTaxFactor() * priceExTax; } public void printCatalogEntry(Writer out) throws IOException { out.write(productNo+"\t"+name+"\t"+getPriceWithTax()); } }