// Items for purchase in Alberta public class AlbertaItem implements Item { // These items all belong to the same catalogue. // This is set by the factory. static Catalogue cat = new Catalogue (); // These items all have the same tax rate. static final int TAX_RATE = 8; // per cent. // It's this catalogue entry. String id; // And this many of them. int quantity; // What price for this many plus tax, in cents? public int totalPrice () { return (quantity * cat. getPrice (id)) * (100+TAX_RATE) / 100; } // How many? (For interface) public int getQuantity () { return quantity; } // What id? (For interface) public String getItemId () { return id; } // What name? (For interface) public String getItemName () { return cat. getName (id); } // What price per each? (For interface) public float getUnitPrice () { return (float) cat. getPrice (id) / 100.0F; } // Total price in float dollars (For interface) public float getTotalPrice () { return (float) totalPrice () / 100.0F; } // Convert to string. public String toString() { // Format a price string. String price = String. valueOf (totalPrice ()); String money = "$" + price. substring (0, price. length () - 2) + "." + price. substring (price. length () - 2); return id + " " + cat. getName (id) + " " + quantity + " " + money; } }