Question: Step 0 Before you get started, you must make one minor revisions to your program. I've revised a property of the ClassSection class ( see
Step
Before you get started, you must make one minor revisions to your program. I've revised a property of the ClassSection class see the UML diagram Now the registrationNumber is an integer type rather than a string. This will make some of our database work easier.
Im also going to allow you to add a property to the ClassSection class see the UML diagram so that the number of enrolled students can be saved as part of the object and does not need to be derived. This is not a better way to handle this, however it does make it easier. This will be optional. If you have things working without this additional property you are able to derive the number of enrolled students only from the array then don't bother adding this.
I've also added some helpful methods to the class to allow you to figure out if a student is already in the section or if the section is full. The method getEnrolledStudentList is crucial to our work. It will take the array of student ids and return it as a string that uses commas to separate each student id number. Use a loop and concatenation to build this method. An array of strings like this:
Apples "Bananas", "Carrots"
would turn into the following string...
"Apples,Bananas,Carrots"
Step
Once you've made your changes to the original program, add in an extra java class that can be used to populate the example database with data. This should mimic what you were doing with the hard coded values in the original program. You should also add five student id numbers make up whatever you want. That is you should add five records to the courses table and five records to the students table of the database by running this new class.
If you complete this, the database should be populated with data.
Step
Now you can revise the original program further.
Rather than using hard coded data to instantiate the instances of the ClassSection class, retrieve the data from the database. At this point the program should work much like the previous version but now all the data is pulled from the database.
Step
To save the data about the enrolled students in each course permanently you'll need to get the array of student ids as a string and then update the database so that this new string is part of the record for the course. You can do this for all the courses just before the program exits.
Step
At this point, your program will work and persist the data verify this by looking at the database after running the program however it will not load the saved student list from the database when the program begins. You should already be loading the data about the section from the database. Make sure to get the string of the enrolled students when you do this. You didn't use it to instantiate the ClassSection objects but you will now use it First turn it back from a string into an array. You can use the split method of a string to break a string into an array of strings. For example:
"Apples,Bananas,Carrots".split
will yield the following array...
Apples "Bananas", "Carrots"
You now need to modify the creation of the instances that occurs at the beginning of the program so that after the objects are instantiated you use the addStudent method to add each of the student ids from this array to the object in question.
Step
You have nearly completed the work. The last step is to use the student ids from the database table of students to verify that an entered student id is valid. When the student using the program the user provides a student id number, run a query to see if this number exists in the database. If it does proceed as normal. If it does not, make the user enter their id number again. Repeat.
Step Celebrate
Congratulations. You now have a program that can persist the data entered by a user to a database. Though we are using a simple filebased database, this technique will work for any software or database system with only slight modification.
Requirements
Don't import any special classes aside from those needed to work with the database and classes of your own creation.
You do not need to modify the database structure. Just the data in it
I will wipe your data and rerun your data insertion program prior to testing. This should provide a clean slate.
Hint
Below you will find a function that can be used in this lab to help you find out how many rows of data you have in your database.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
