// LANDSCAPE GARDENING QUOTE SUMMARY // Frans Coenen // University of Liverpool // 21 April 2013 public class QuoteSummary { // ------------------- FIELDS ------------------------ /** The month that the summary applies to. */ private String month = null; /** Total square metres of lawn purchased. */ private double lawnTotalArea = 0.0; /** Total square metres of concrete patio purchased. */ private double patioTotalArea = 0.0; /** Total number of water features purchased. */ private int waterFeatureTotal = 0; /** Total lawn monthly value. */ private double lawnTotalValue = 0.0; /** Total concrete patio monthly value. */ private double patioTotalValue = 0.0; /** Total water features monthly value. */ private double waterFeatureTotalValue = 0.0; /** Total total monthly value. */ private double totalTotalValue = 0.0; // ---------------- CONSTRUCTORS --------------------- /** Ome argument constructor. @param mth the month that the summary applies to. */ public QuoteSummary(String mth) { month = mth; } // ---------------- ADD TO METHODS --------------------- /** Method to add to total lawn area given a new area defined in terms of length and width. @param length the length of the lawn area to be added. @param width the width of the lawn area to be added. @param materialCost the material cost for the lawn area to be added. */ public void addToLawnTotalArea(double length, double width, double materialCost) { lawnTotalArea = lawnTotalArea + (length*width); lawnTotalValue = lawnTotalValue + (length*width*materialCost); } /** Method to add to total patio area given a new area defined in terms of length and width. @param length the length of the patio area to be added. @param width the width of the patio area to be added. @param materialCost the material cost for the patio area to be added. */ public void addToPatioTotalArea(double length, double width, double materialCost) { patioTotalArea = patioTotalArea + (length*width); patioTotalValue = patioTotalValue + (length*width*materialCost); } /** Method to add to total quantity of water features given a new quantity. @param quantity the quantity to be added. @param materialCost the material cost for the water feature(s) to be added. */ public void addToWaterFeatureTotal(int quantity, double materialCost) { waterFeatureTotal = waterFeatureTotal + quantity; waterFeatureTotalValue = waterFeatureTotalValue + (quantity*materialCost); } // ---------------- CALCULATION METHODS --------------------- public void calculateTotal() { totalTotalValue = lawnTotalValue + patioTotalValue + waterFeatureTotalValue; } // ---------------- OUTPUT METHODS --------------------- /** To string method. */ public String toString() { String s1 = "---------------------------------------------------------------\n"; String s2 = "Month: " + month + "\n"; String s3 = "---------------------------------------------------------------\n"; String s4 = " Total Total m^2 Total num Total\n"; String s5 = "Working item Purchased Purchased Monthly\n"; String s6 = " Costs Value (£)\n"; String s7 = "---------------------------------------------------------------\n"; String s8 = " Lawn " + lawnTotalArea + "\t\t\t" + lawnTotalValue + "\n"; String s9 = " Concrete Patio " + patioTotalArea + "\t\t\t" + patioTotalValue + "\n"; String s10 = " Water Feature\t\t\t" + waterFeatureTotal + "\t" + waterFeatureTotalValue + "\n"; String s11 = "---------------------------------------------------------------\n"; String s12 = "\t\t\t\t\t\t" + totalTotalValue + "\n"; String s13 = "---------------------------------------------------------------\n"; // Return return(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13); } }