/** * demo code to show how can Catalog can be used by trainers or site managers * * @param args */ public static void main(String[] args) { Messenger messenger = SimpleMessenger.getInstance(); Catalog catalog = new Catalog("Java S2", messenger); TraineeCatalogInterface traineeInterface = catalog; Trainee florin = new Trainee("florin", "", messenger, traineeInterface); Trainee radu = new Trainee("radu", "", messenger, traineeInterface); Trainee andrei = new Trainee("andrei", "", messenger, traineeInterface); Trainee ciprian = new Trainee("ciprian", "", messenger, traineeInterface); SiteManagerCatalogInterface siteManagerInterface = catalog; SiteManager siteManager = new SiteManager("diana", "*****@*****.**", siteManagerInterface, messenger); siteManager.addTrainee(florin); siteManager.addTrainee(radu); siteManager.addTrainee(andrei); siteManager.addTrainee(ciprian); TrainerCatalogInterface trainerInterface = catalog; Trainer trainer = new Trainer("madalin", "*****@*****.**", trainerInterface, messenger); try { trainer.addGrade("florin", 10); } catch (IllegalStateException e) { System.out.println(e.getMessage()); } try { siteManager.printGrades("florin"); } catch (IllegalStateException e) { System.out.println(e.getMessage()); } siteManager.startTraining(trainer); work(trainer); work(siteManager); ciprian.sendFeedback(trainer); radu.sendFeedback(siteManager); siteManager.sendFeedback(trainer); try { radu.sendFeedback(ciprian); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); } try { trainer.sendFeedback(trainer); } catch (IllegalArgumentException e) { System.out.println(e.getMessage()); } Trainee daniel = new Trainee("daniel", "", messenger, traineeInterface); try { siteManager.addTrainee(daniel); } catch (IllegalStateException e) { System.out.println(e.getMessage()); } }
/** * the site manager works with the catalog * * @param siteManager */ private static void work(SiteManager siteManager) { siteManager.printGrades("radu"); siteManager.printCatalog(); }