// LANDSCAPE GARDENING QUOTE // Frans Coenen // University of Liverpool // 19 April 2013 //import java.io.*; // PrintWriter class class Quote { // ------------------- FIELDS ------------------------ /** Month when quote made. */ private String month = null; /** Lawn Quote */ private QuoteItemType1 lawn = null; /** Patio Quote */ private QuoteItemType1 patio = null; /** Water Feature Quote */ private QuoteItemType2 waterFeature = null; /** Total installation time (hours). */ private double totalInstallationTime = 0.0; /** The labour cost per hour (installation times are given in minutes!). */ private double labourCost = 0.0; /** Total material cost. */ private double totalMaterialCost = 0.0; /** Total Installation Time. */ private double totalLabourCost = 0.0; /** Total job cost. */ private double totalJobCost = 0.0; // ---------------- CONSTRUCTORS --------------------- /** Five argument constructor. @param mth the month the quote was made. @param ln quote for the lawn element of the total landscape gardening quote. @param pt quote for the patio element of the total landscape gardening quote. @param wf quote for the water feature element of the total landscape gardening quote. @param lc the labour cost per hour (installation times are given in minutes!). */ public Quote(String mth, QuoteItemType1 ln, QuoteItemType1 pt, QuoteItemType2 wf, double lc) { month = mth; lawn = ln; patio = pt; waterFeature = wf; labourCost = lc; } // ---------------- CALCULATION METHODS --------------------- /** Method to calculate totalLabourCost + totalMaterialCost = totalJobCost. */ public void calculateCosts() { // Determine total installation time totalInstallationTime = (lawn.getTotalInstallationTime() + patio.getTotalInstallationTime() + waterFeature.getTotalInstallationTime())/60.0; // Determine labour cost totalLabourCost = totalInstallationTime * labourCost; // Determine total material cost totalMaterialCost = lawn.getTotalMaterialCost() + patio.getTotalMaterialCost() + waterFeature.getTotalMaterialCost(); totalJobCost = totalMaterialCost + totalLabourCost ; } // ---------------- OUTPUT METHODS --------------------- /** To string method. */ public String toString() { String s = "Month = " + month + "\n[1]\n" + lawn + "\n[2]\n" + patio + "\n[3]\n" + waterFeature + "\nWorking Costs:\nTotal Time to Complete the work (labour) in hours = " + Utility.twoDecPlaces(totalInstallationTime) + "\nCost of the work (per hour) = " + labourCost + "\nTotal cost of the work (labour) = " + Utility.twoDecPlaces(totalLabourCost) + "\n\nTotal fee payable by the customer (labour + materials) = " + Utility.twoDecPlaces(totalJobCost) + "\n"; return(s); } }