ICS3U School Database Project: SchoolDB

The purpose of this extended, in-class project is to enable you to gain familiarity with object-based arrays and the complexities of designing and implementing an application involving multiple classes.

This project also bears some resemblance to code and data structures of the interrelated classes within the Bingo Trilogy you are currently in the midst of developing.

 

  1. DAY 0
    1. Review this UML diagram.
    2. Create project called SchoolDB, a driver by the same name, and the dependent classes: Subject and Student.
    3. Following a stepwise refinement strategy, add the method headers for all three classes with the aim of getting the entire project to compile without error.
    4. Now, provide implementations for the bodies of the methods of Subject and Student.
    5. Add the simplest of statements in the main method of your driver to test your methods.
  2. DAY 1
    1. Review this UML diagram.
    2. Add the required instance fields for all three classes.
    3. Provide implementations for the additional Subject and Student methods.
    4. Add the data file Subjects.txt to the root folder of this project. The data in the Subjects.txt file consists of one record for each of the courses ICS3U students are enrolled in. Each field within the record is separated by a single Tab character. The number of courses in the file appears as the first entry in the file.
    5. Implement the loadSubjects() method of SchoolDB. The method is to use the Scanner object to process the file. The method first opens the file (see your earlier iTunes project), reads the first integer (to assist with the instantiation of the calendar array) and then reads all remaining records, loading each one as it goes, into the calendar array.
    6. On return from the loadSubjects() method, add a for..each loop to the main to generate a console display of the calendar array for confirmation.
    7. Implement similar statements to accommodate the Students.txt file. Don't forget to display the names to the console window upon return from the loadStudents() method.
  3. DAY 2.
    1. Review this UML diagram.
    2. Add the data file Selections.txt to the root folder of this project. As you can see, records exist for each for the courses you are enrolled in. Together, we'll agree on the diamonds for each course.
    3. Implement the loadSelections() method of SchoolDB. Records are to be read until there are no more. For each record, the name and code fields are used to retrieve references to the Student and Subject objects respectively. Implement the bodies of the getStudent(String name) and getSubject(String code) methods to assist with this. These references, along with the slot field are used to add a Subject to the Student's timetable.
    4. Upon return from the loadSelections() method, have the main method iterate over the entire body array, displaying the Student records to the console window.
  4. DAY 3
    1. With the arrays in our small database populated (calendar and body), we can formulate simple queries (one array only) or compound queries (interrelationships between the arrays) to produce Result Sets consisting of the data that matches our criteria.
    2. Review this UML diagram.
    3. The UML requires that 5 queries be implemented, each taking the form of a new method in the driver and, possibly new supporting methods added to either the Student or Subject classes. Each query returns the data that match the respective criteria in the form of an ArrayList of Objects (either ArrayList<Student> or ArrayList<Subject>)
    4. In the main method, the call to each query will be preceded with a Dialog request for user input. Upon return from the query, the contents of the ArrayList is to be displayed to the console window.
  5. DAY 4
    1. Create a new Project entitled SortingObjects, add the file Subjects.txt (from your SchoolDB Project) to the root folder of SortingObjects and add the SchoolDB project to the Build Path of SortingObjects.
    2. Add a token driver by the same name.
    3. Add the new class SubjectSE to the SortingObject Project defined by the UML diagram that extends the Subject class and implements the Comparable<T> interface.
    4. Upgrade Subject's toString method to format all four fields exactly as depicted in this text file. Use String.format to perform column alignment (as in %-15s, etc). Do NOT use \t. Run the SortingObject's driver to confirm.
    5. Review this Tutorial on Making Dialogs. JOptionPane provides an number of overloaded showInputDialog() method. Using the one that offers a dropdown box (right), present the list of available rooms in the dropdown box for the user to choose from. Handle the event that the user may wish to Cancel instead of making a valid selection, otherwise arrange to have the SubjectSEs thast use the selected room displayed to the console window similar to this sample. Be sure to format column alignment as depicted.