Ejemplo n.º 1
0
  /**
   * the trainer works with the catalog
   *
   * @param trainer
   */
  private static void work(Trainer trainer) {
    trainer.addGrade("florin", 10);
    trainer.addGrade("florin", 9);

    try {
      trainer.addGrade("dana", 4);
    } catch (IllegalArgumentException e) {
      System.out.println(e.getMessage());
    }

    trainer.addGrade("radu", 9);
    trainer.addGrade("radu", 10);

    trainer.addGrade("andrei", 9);
    trainer.addGrade("florin", 9);

    try {
      trainer.addGrade("florin", 11);
    } catch (IllegalArgumentException e) {
      System.out.println(e.getMessage());
    }

    trainer.addGrade("ciprian", 8);
    trainer.addGrade("ciprian", 9);

    trainer.printGrades("radu");

    trainer.addGrade("radu", 10);
    trainer.printCatalog();
  }
Ejemplo n.º 2
0
  /**
   * 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());
    }
  }