In this lab you will work with
polymorphism and recursion. You will also read existing code and
comment it. You will do something commonly done in industry. You are
given a half finished program from a previous employee and told to
finish it.
Objective:
You will work with
What you must do:
The previous employee wrote a GUI and some basic polymorphic code to a
simple college personel record program and then left to company.
You need to finish it. Copy the code from eagle using
cp ~jsantore/lab5-start.zip .
or
Download it from the web
and then look at what you have. compile it and run it. You
will have a GUI for imputing data. There are several labeled text
fields and buttons. There is also a combo box (the selectable menu) for choosing what sort of records to work with.
You need to do the following tasks:
- Over ride getExtraField() in each of the three derived classes.
(Student, Faculty and Staff), it should be left empty in BSCPerson
- this method should return the rank for a faculty member, the unit for a staff member, or the gpa for a student.
- Finish the toString methods in BSCPerson and all of the derived classes
- this method should return the value of the class as a string.
All instance variables (whether declared in the class or derived) must
be printed.
- Implement the lookup method in the App class. this method takes
the last name of a record holder as a string. You must implement
recursive binary search to find the appropriate record (if it exists).
If it exists, then you must insert the appropriate values from the
records into the right text boxes (feel free to put the extra field
(GPS, rank or unit) into each of the three text boxes if that is easier
than using the instanceOf operator.) Your method must also print the
record out to the terminal window. You may only use BSCPerson variables
for your records. In particular, in this method (and any that you call
from this method) you may not use any variables on types Student,
Faculty or Staff. (Of course you will use values of those types, just
not variables.). If the requested record does not exist in the list,
display and error message telling the user so.
- Implement the addRecord method in the App class. This method
takes a BSCPerson as its parameter (I've already created it, you just
use it) and should insert that BSCPerson into the list of people
(_list) in the appropriate spot alphabetically. Use what ever algorithm
you with to find the appropriate spot.
- Your predecessor at this company was pretty poor with
documentation. The code is poorly commented and there is no
documentation. You must comment to the code to explain what is going on
and then write some documentation (your normal readme file) that
explains what you've done,. why, and how the whole program works.
In addition, there is one more requirement, you may write any new code
you like, but you may not change any of the existing methods that have
been written for you unless you have your instructors explicit
persmission.
When you are done, zip up all the code and mail it to me in the usual way.