An InfoRecord object is meant to contain the
information about one student. The data elements for a student consist
of:
string name;
// Students name in the form: last, first
int
id; //
A 4-digit ID number
float
gpa; // Grade
Point Average
int
level; // A class level
number (1 - 4)
string major;
// Student's course of study
The member functions of InfoRecord allow a client
programmer (you) to read an entire InfoRecord from a file or from the keyboard,
display an InfoRecord on the screen in a standard form, write an InfoRecord
to a file in the same form as it was in the input file, compare one InfoRecord
to another (based on the name), and test for validity of an InfoRecord
(valid if ID >= 0). Each line of thestudents.dat contains
a name (form shown above), an ID number, a GPA in the form x.xx, a class
level number (1 for Fr. . . 4 for Sr), a major, and a newline character.
A DataBase object is essentially a flexible size collection of InfoRecords with associated data to keep track of the allocation and usage of the array. The client programmer has access to member functions to do associative accesses of a specific InfoRecord in the collection based on either an ID number or a name (or partial name), to add an InfoRecord to the collection, to delete an InfoRecord from the collection (by specifying an ID number or a name), to display on the screen the entire collection of InfoRecords, to display on the screen the names and GPAs of students in rank order, to open the data file and read all InfoRecords into the collection, and to close the database (after possibly writing the updated collection to a file).
Your program should allow all single-letter commands to be entered in either uppercase or lowercase. The response to the commands must be reasonable even if something is done wrong by the user of your program. For example, if an ID FIND or a NAME FIND fails, an error message should be the result; if, when doing an ADD, invalid data is entered, the program must be forgiving; if an invalid letter is entered for a command, the program must be forgiving. You will find that the way in which the member functions are written will make most such situations easy to deal with. You should study the implementations of InfoRecord and DataBase before beginning your program to find out just how much these objects can do for you.
Demonstrate that the program works by running it and entering the following commands.
L
i { find 3007 }
D { delete Bailey }
n { find Oop }
d { delete 2100 }
N { find Smith, T }
i { find 3861 }
d { delete 8023 }
D { delete 8099 }
n { find Peach, Miss }
I { find 1806 }
L
R
A { add Capp, Andy ID=4117 you make up the rest }
a { add Abner, Daisy Mae ID=1426 you make up the rest }
N { find Dallas, Steve }
d { delete 3861 }
i { find 4117 }
A { add Palooka, Joe ID=7633 you make up the rest }
i { find 6225 }
A { add Smith, Tina ID=3008 }
N { find Abner }
r
l
Q
Hand in a printout of your .cpp file containing
the source program and a printout showing the results of performing the
above sequence of commands. Also, rename your .cpp file to
be yourlastname-p1.cpp and copy it to the hand-in folder
for your section of COSC 310 on the P: drive.