@Test
  public void test1() throws Exception {

    Student denise = studentHome.create("823", "Denise Smith");

    Course power = courseHome.create("220", "Power J2EE Programming");

    Enroller enroller = enrollerHome.create();
    enroller.enroll("823", "220");
    enroller.enroll("823", "333");
    enroller.enroll("823", "777");
    enroller.enroll("456", "777");
    enroller.enroll("388", "777");

    System.out.println(denise.getName() + ":");
    ArrayList courses = denise.getCourseIds();
    Iterator i = courses.iterator();
    while (i.hasNext()) {
      String courseId = (String) i.next();
      Course course = courseHome.findByPrimaryKey(courseId);
      System.out.println(courseId + " " + course.getName());
    }

    System.out.println();

    Course intro = courseHome.findByPrimaryKey("777");
    System.out.println(intro.getName() + ":");
    courses = intro.getStudentIds();
    i = courses.iterator();
    while (i.hasNext()) {
      String studentId = (String) i.next();
      Student student = studentHome.findByPrimaryKey(studentId);
      System.out.println(studentId + " " + student.getName());
    }
  }
  public String getRosterReport() {
    StringBuilder buffer = new StringBuilder();

    buffer.append(ROSTER_REPORT_HEADER);

    for (Student student : students) {
      buffer.append(student.getName());
      buffer.append(NEWLINE);
    }

    buffer.append(ROSTER_REPORT_FOOTER + students.size() + NEWLINE);

    return buffer.toString();
  }
示例#3
0
 public static void GameOver(Student player, Teacher teacher, int battles) {
   System.out.println("The classwork was overwhelming! Beaten by " + teacher.getName());
   System.out.println("Winner info:");
   System.out.println("Name: " + teacher.getName());
   System.out.println("Strength: " + teacher.getStrength());
   System.out.println("Hitpoints: " + teacher.getHP());
   teacher.showAbilities();
   System.out.println();
   System.out.println("Loser info:");
   System.out.println("Name: " + player.getName());
   System.out.println("Strength: " + player.getStrength());
   System.out.println("Hitpoints: " + player.getHP());
   System.out.println("Classes attended: " + battles);
   player.showPlayerInventory(false);
   System.exit(0);
 }
示例#4
0
  public static void WinScreen(Student player, Teacher teacher, int battles) {
    if (teacher == null) {
      Teacher teacher1 = new Teacher();
      teacher = teacher1;
    }
    System.out.println(
        "Congratulations " + player + ", you passed " + teacher.getName() + "'s class!");
    System.out.println("Winner info:");
    System.out.println("Name: " + player.getName());
    System.out.println("Strength: " + player.getStrength());
    System.out.println("Hitpoints: " + player.getHP());
    System.out.println("Classes attended: " + battles);
    player.showPlayerInventory(false);

    System.out.println();
    System.out.println("Loser info:");
    System.out.println("Name: " + teacher.getName());
    System.out.println("Strength: " + teacher.getStrength());
    teacher.showAbilities();
    System.exit(0);
  }
 public int compareTo(Student other) {
   if (score == other.getScore()) return name.compareTo(other.getName());
   return other.getScore() - score;
 }
示例#6
0
文件: Two.java 项目: rajesh4java/ht
  public static void main(String[] args) {

    Student obj[] = new Student[5];

    for (Student temp : obj) System.out.println(temp.getRoll() + "\t" + temp.getName());
  }
示例#7
0
文件: Test.java 项目: TauOmicronMu/SW
  public static void main(String[] args) {

    Module sw = new Module("Software Workshop", "Jon Rowe");

    System.out.println(sw);

    System.out.println(sw.getName());
    System.out.println(sw.getLecturer());

    System.out.println("changing lecturer");
    sw.setLecturer("Martin Escardo");

    System.out.println(sw);

    Student alf = new Student("Alfred Smith", 12345);
    Student bob = new Student("Bob Mascheranas", 24680);

    System.out.println(alf);
    System.out.println(alf.getName());
    System.out.println(alf.getId());

    System.out.println("changing id");
    alf.setId(54321);
    System.out.println(alf);

    alf.setModule(0, sw);
    alf.setModule(1, new Module("Foundations", "Dan Ghica"));
    alf.setModule(2, new Module("Intro to AI", "Volker Sorge"));

    bob.setModule(0, sw);
    bob.setModule(1, new Module("Foundations", "Dan Ghica"));
    bob.setModule(2, new Module("Intro to AI", "Volker Sorge"));

    TutorGroup TG = new TutorGroup("Nick Hawes");

    System.out.println("Does sw = sw?");
    System.out.println(sw.equals(sw));

    System.out.println("Is alf on sw?");
    System.out.println(alf.onModule(sw));

    System.out.println("Check: TutorGroup toString()");
    System.out.println(TG);

    System.out.println("Check: TutorGroup getStudents()");
    System.out.println(TG.getStudents());

    System.out.println("Check: TutorGroup addStudent()");
    TG.addStudent(bob);
    System.out.println(TG.getStudents());

    System.out.println("Check: TutorGroup setTutor()");
    TG.setTutor("Achim Jung");
    System.out.println(TG);

    System.out.println("Check: TutorGroup getTutor()");
    System.out.println(TG.getTutor());

    // System.out.println(alf.getModule(1));

    for (int i = 0; i < 3; i++) {
      System.out.println(alf.getModule(i));
    }
  }