/** * Outputs data to output service. outputType cannot be null. * * @param outputType Output strategy being used. * @throws NullOrEmptyArgumentException Custom exception class. */ @Override public final void output(OutputService outputType) throws NullOrEmptyArgumentException { if (outputType == null) { throw new NullOrEmptyArgumentException("outputType is null in output in SalesReport"); } try { outputType.outputData(salesReport.output()); } catch (NullOrEmptyArgumentException e) { System.out.println(e + " could not output in output in SalesReport."); } }
/** * Adding data to cumulative daily sales report. hours cannot be less than 0 and fee cannot be * less than 1.50 * * @param hours hours car was parked. * @param fee Fee's incurred during that time. * @throws NullOrEmptyArgumentException */ @Override public final void addToSalesReport(double hours, double fee) throws NullOrEmptyArgumentException { if (hours <= 0 || fee < 1.50) { throw new NullOrEmptyArgumentException( " hours or fee is out of range: Sales Report addToSalesReport method"); } try { salesReport.newCar(hours, fee); } catch (NullOrEmptyArgumentException e) { // endless try catch System.out.println( "Cannot pass hours of fee because one or more are null to new car method inside addToSalesReport"); } }
/** * Returns the total daily sales. This is useful for the file service. * * @return totalDailyFee- the total fee for the garage for the day. */ @Override public final double getTotalDailySales() { return salesReport.getTotalDailySales(); }
/** * Returns the total daily cars for the garage. This is useful for the file service. * * @return totalDailyCars- the total cars for the garage for the day. */ @Override public final int getTotalDailyCars() { return salesReport.getTotalDailyCars(); }