// LANDSCAPE GARDENING TYPE 1 QUOTE // Frans Coenen // University of Liverpool // 18 April 2013 public class QuoteItemType1 extends QuoteItem { // ------------------- FIELDS ------------------------ /** The length of the type 1 landscape item. */ private double length = 0.0; /** The width of the type1 landscape item. */ private double width = 0.0; /** The area covered by the type 1 landscape item. */ private double area = 0.0; // ---------------- CONSTRUCTORS --------------------- /** Five argument constructor. @param name the name for this landscape gardening item. @param ln the length of the type 1 landscape gardening item. @param wd the width of the type 1 landscape gardening item. @param unitMC the unit material cost for the type 1 landscape gardening item. @param unitIT the unit installation time for the type 1 landscape gardening item. */ public QuoteItemType1(String name, double ln, double wd, double unitMC, double unitIT) { super(name,unitMC,unitIT); length = ln; width = wd; // Calculate costs calculateCosts(); } /** Method to calculate total installation time and total material cost for this type 1 landscape gardening item. */ private void calculateCosts() { // Calculate area area = length * width; // Calculate total installation time totalInstallationTime = area * unitInstallationTime; // Calculate total material cost totalMaterialCost = area * unitMaterialCost; } // ---------------- OUTPUT METHODS --------------------- /** To string method. */ public String toString() { String s = "Length and width of the " + itemName + " = " + length + " x " + width + "(m)\nTotal area of the " + itemName + " = " + area + " (m^2)\nUnit cost of the " + itemName + " = £" + unitMaterialCost + " (per m^2)\nTotal cost of the " + itemName + " = £" + Utility.twoDecPlaces(totalMaterialCost) + "\nTotal installation time = " + totalInstallationTime + "\n"; return(s); } }