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.
- DAY 0
- Review this UML diagram.
- Create project called SchoolDB, a driver by the same name, and the dependent classes: Subject and Student.
- 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.
- Now, provide implementations for the bodies of the methods of Subject and Student.
- Add the simplest of statements in the main method of your driver to test your methods.
- DAY 1
- Review this UML diagram.
- Add the required instance fields for all three classes.
Provide implementations for the additional Subject and Student methods.
- 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.
- 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.
- 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.
- 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.
- DAY 2.
- Review this UML diagram.
- 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.
- 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.
Upon return from the loadSelections() method, have the main method iterate over the entire body array, displaying the Student records to the console window.
- DAY 3
- 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.
- Review this UML diagram.
- 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>)
- 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.
- DAY 4
- 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.
- Add a token driver by the same name.
- 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.
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.
- 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.