/** Creates a new service report generator object which creates a new * provider directory (service report). */ public ServiceReportGenerator() { try { Services services = new Services(); services.open(); //Create a new provider directory report = new ProviderDirectory(); //Get all services List <Service> allServices = services.getAllOrderedByName(); //Add all services to provider directory foreach (Service aService in allServices) { report.addDetail(aService.getName(), aService.getCode(), aService.getFee()); } services.close(); } catch (Exception ex) { //occurs if the file cannot be created report.addErrorMessage(ex.Message); } //catch (ParseException ex) //{ // //occurs if the file format is incorrect // report.addErrorMessage(ex.getMessage()); //} }//default constructor
}//verifyMember // Generates a provider directory and sends it to provider by email private void receiveDirectory() { try { //generate the report ServiceReportGenerator generator = new ServiceReportGenerator(); ProviderDirectory theReport = generator.getReport(); //Send directory by email to the provider theReport.sendByEmail(theProvider.getName() + " Provider Directory"); //Display success confirmation on provider terminal ui.message("Your directory has been sent to you by email"); } catch (Exception ex) { //occurs if the file cannot be created ui.errorMessage(ex.Message); } }//receiveDirectory