CSC216 Lab 01 - Installation and Project Creation

CSC216 Lab 01 - StudentDirectory Overview

CSC216 Lab 01: StudentDirectory Overview

You have been provided StudentDirectory for Lab 01. However, when provided code, you should always inspect it to understand the functionality, learn new things about programming, and maybe find bugs (hopefully not, but bugs are possible!).

StudentDirectory represents a list of Student records in our system.

StudentDirectory State

StudentDirectory has an ArrayList of Students that represent the student directory for the university.

There is also a constant value for the hash algorithm used to hash the passwords when adding a new Student. We’re using SHA-256. By providing the hash algorithm as a constant, we reduce the chance of throwing a NoSuchAlgorithmException due to a mistype.

StudentDirectory Constructor

The StudentDirectory constructor initializes the studentDirectory field by calling the newStudentDirectory() method.

newStudentDirectory()

This method supports the functionality for a new student directory described in [Use Case 2: Create Student Directory]. studentDirectory is updated to refer to a new ArrayList of Students.

loadStudentsFromFile()

This method supports the functionality for loading a list of student records from a file as described in [Use Case 3: Load Student Directory]. If the call to StudentRecordIO.readStudentRecords() throws a FileNotFoundException a new IllegalArgumentException is thrown. The provided message may be used in a dialog as described in [Invalid File].

saveStudentDirectory()

This method saves the studentDirectory to the given file described in [Use Case 4: Save Student Directory]. If StudentRecordIO.writeStudentRecords() throws an IOException a new IllegalArgumentException is thrown. The provided message may be used in a dialog as described in [Error Saving].

addStudent()

This method supports the functionality for adding a Student to the list of students as described in [Use Case 5: Add Student to Student Directory]. The method also covers Alternative Flows for Use Case 5.

The first few lines in the method ensure that there are values for the password and repeatPassword parameters. If there are values, then these values are hashed. Passwords should never be stored in plain text! That’s a security vulnerability (if anyone got ahold of your student file with plain text passwords, they could register you in really boring classes at really bad times!) We use the private helper method hashString() to hash the provided passwords. We use a hashing algorithm, in this case SHA-256, to transform the plain text to a hashed output. We then encode the output using a 64-bit encoder so that the binary data of the hashed password is represented in an ASCII format. This is important to minimize issues with the build process. Do NOT change the hashString() method!

After hashing the passwords, checks are done to ensure that the student can be successfully added to the StudentDirectory.

By returning false the method will trigger [Non-unique ID] in the GUI.

removeStudent()

This method supports the functionality for removing a Student from the list of students as described in [Use Case 6: Remove Student from Student Directory].

getStudentDirectory()

This method returns a 2D array, where each row is a Student and the columns are for the firstName, lastName, and id. The 2D array is required so that the information may be displayed in the table used in the GUI.

Javadoc your Code

StudentDirectory is already fully Javadoced, but if you would like to clarify the documentation to help your understanding of the code, do so.

Run CheckStyle to ensure that your Javadoc has all elements.

Reference: Staging and Pushing to GitHub

GitHub Resources:

Push to GitHub

Push your PackScheduler project to GitHub

  • Add the unstaged changes to the index.
  • Commit and push changes. Remember to use a meaningful commit message describing how you have changed the code.

Reminder: Interpreting Jenkins

Check the following items on Jenkins for your last build and use the results to estimate your grade:

Check Jenkins

At this point your project should build on Jenkins, hopefully with a green ball! If not, work through Jenkins’s feedback to fix any errors with the integration of your code with the provided code. All tests should be passing before you walk through the GUI.