@Test
 public void test_setCorrectCode() {
   System.out.println("Test correct Code is set...");
   CourseEnrollment C = new CourseEnrollment("java", 4, "A");
   C.setCourseCode("c++");
   assertTrue(C.getCourseCode().equals("c++"));
 }
Example #2
0
  /** @param args */
  public static void main(String[] args) {

    CourseEnrollment myCourse;
    Transcript myTranscript = new Transcript();

    // temp variables
    String code, grade;
    int credits;

    System.out.println("Welcome to the transcript application.\n");

    while (myTranscript.getUserChoice().equalsIgnoreCase("y")) {
      Scanner sc = new Scanner(System.in);
      myCourse = new CourseEnrollment();
      code = Validator.validateCourseCode(sc, "Enter course:\t");
      myCourse.setCourseCode(code);

      credits = Validator.validateCredits(sc, "Enter credits:\t", 0, 4);
      myCourse.setCredits(credits);

      grade = Validator.validateGrade(sc, "Enter grade:\t");
      myCourse.setGrade(grade);

      myTranscript.addCourse(myCourse);
      myTranscript.getOverallGPA();
      System.out.print("\nAnother line item? (y/n):   ");
      myTranscript.setUserChoice(sc.next());
    }
    System.out.println("\nCourse\t    Credits\t  Grade\t  Quality Points");
    System.out.println("\n------------------------------------------------------");
    System.out.println(myTranscript);
  }