This course has already ended.

⌛⌛ Student register

Of the submission problem

Plussa should now accept submissions for this task.

A class for testing your code and example test input and output files are available for the exercise in the remote material repository. The files are in the round4/studentregister directory.

Place your code into files named Student.java, Course.java, Attainment.java and StudentRegister.java. These file must be in the /round4/studentregister/ directory.

Implement classes Student, Course, Attainment and StudentRegister for maintaining student data. The public functionality of the classes is described below. You are free to implement internal (private) details as you wish.

  • Student

    • Stores the name and student number of a student.

    • Public constructors and member functions:

      • Constructor Student(String name, String studentNumber): initalizes the Student object with the name and student number received as parameters.

      • Member functions getName() and getStudentNumber(): return the name and student number, respectively, as String.

  • Course

    • Stores the code, name and credits of a course.

    • Public constructors and member functions:

      • Contructor Course((String code, String name, int credits): initalizes the Course object with the code, name and credits received as parameters.

      • Member functions getCode(), getName() ja getCredits(): return the code, name and credits of the course, respectively. The first two as String and the last as int.

  • Attainment

    • Describes a course attainment as a combination of course code, student number and grade.

    • Public constructors and member functions:

      • Constructor Attainment(String courseCode, String studentNumber, int grade): initializes the Attainment object with the course code, student number and grade received as parameters.

      • Member functions getCourseCode(), getStudentNumber() and getGrade(): return the attainment’s course code, student number and grade, respectively. The first two as String and the last as int.

  • StudentRegister

    • Implements a simple student register that maintains information about students, courses and course attainments.

    • Public constructors and member functions:

      • Constructor StudentRegister(): initializes an empty StudentRegister object that does not yet contain information about students, courses or attainments.

      • Member function getStudents(): returns an ArrayList<Student> list of all students currently stored in the register. The students are in alphabetical order of their names.

      • Member function getCourses(): returns an ArrayList<course> list of all courses currently stored in the register. The courses are in alphabetical order of their names.

      • Member function addStudent(Student student): adds student into the register.

      • Member function addCourse(Course course): adds course into the register.

      • Member function addAttainment(Attainment att): adds attainment into the register.

      • Member function printStudentAttainments(String studentNumber, String order): prints all registered course attainments of the specified student to the screen. The second parameter order specifies in which order the attainments should be printed.

        • If the register does not contain a student whose student number is studentNumber, print a message of form "Unknown student number: studentNumber".

        • First, print a header line of form "studentName (studentNumber):".

        • After the header line, print each attainment in the form "  courseCode courseName: grade". Please, note the two spaces in the beginning.

          • If order is "by name", the attainments are printed in the alphabetical order of course names. Use the compareTo function from the String class as the comparison function for sorting. Since the order established by compareTo is case sensitive, the upper case letters come before the lower case letters. You do not need to worry now about the case-sensitivity in sorting. It is just something you should now as a programmer.

          • If order is "by code", the attainments are printed in the alphabetical order of course codes. Apply the compareTo function of the String class also here as a comparison function.

          • Otherwise the attainments are printed in the order they were stored into the register: The first the attainment that was stored the earliest and last the attainment that was stored the latest.

      • Member function printStudentAttainments(String studentNumber): prints all registered course attainments of the specified student to the screen in the order they were stored into the register. The only difference between this function and the preceding printStudentAttainments function is the missing order parameter.

      • Please, examine the output file given in the supplementary material for details of printing.

Testing the implementation

You may test your class implementations by using the test program given in the file StudentRegisterTest.java, the example data in the files students.txt, courses.txt and attainments.txt, and the example output in the file output.txt. Place these files and your own classes into the same directory, compile the program, for example, as javac *.java, and run the test as java StudentRegisterTest students.txt courses.txt attainments.txt. The program output should be identical with the example output given in the file output.txt.

Submitting

Make sure before submission that your classes are in the /round4/studentregister/ directory and that you have pushed the latest changes to your personal remote repository. When ready, enter the URL of your personal remote directory in the field below. The URL is https://course-gitlab.tuni.fi/compcs140-spring2023/------, where ------ denotes your Tampere university username.

A+ presents the exercise submission form here.

Posting submission...