Note, there is a potential issue with the UML diagram, when you create the array that _studentList points to, if you create an array of objects of type Student (one option) rather than an array of pointers to objects of type student (the other option) then you will need a default contructor in the Student class) if you decide to go this way, you will need to have a default contructor, and probably two mutators. You may may these changes to the UML if you like, but make sure to detail it in the readme file.
This Lab is something of a cross between a lab and a homework assignment. We have not had alot of new concepts covered since the last lab, so this lab will be a little smaller, have a quick due date and be worth less of your grade than most others. We will have another new lab, full sized this time, next week.
The important concepts in this lab.
There are no files for this lab. You will be createing two cpp and two .h files from scratch to implement the two classes.
create a lab4 directory and move into it
mkdir lab4
cd lab4
.
Here is the UML for Lab4:
Note that there are only two classes. You can put the main function at the bottem
of the cpp file that defines the ClassList class. Your assignment is to implement
the two classes layed out in this UML and the main function. Specifics are described
below.
Student class
This class should be easy for all of you, you have done something similar before. You need to implement three member functions.
There are two accessors (getGPA and getName) which simply return the values of the two properties.
You also need to implement the constructor to initialize the properties with values passed in as parameters to the constructor.
ClassList class
This class is a little more complicated. In this class you can see from the UML that the one instance variable is a Student pointer. However it will point to the beginning of a dynamic array of students. So you need to declare it as a Student pointer in the header file.
The contructor: in the ClassList contructor, first set the _studentList property to NULL (to initialize the variable) and then call the member fucntion addStudents.
in addStudents: This method should first query the user for the number of students that will be added. Then it should create an array with exactly that many elements. Finally, it should have a loop to query the user for each student's name and initial GPA, create the student, and then add the student to the array.
findStudent takes a student name, searches for that student in the
array, and prints out a message with the location of that student in the array.
finally ClassList::run should loop asking the user which student (s)he wants to find until the user types quit.
The main function should create a ClassList object, and call run on that object.
Because this is a fairly small project, you are encouraged to find your own best beginning point for writing your code.
when you are done, write the readme.
When you are ready to submit, zip up your lab4 directory. Go to your home directory
and do the following.
zip -r Lab4Solution.zip lab4
and submit it.
(best way is probably email, in which case you can ftp your zip file to your
webhost (w:) drive and submit it as an attachement.
Due By Midnight Friday Oct 12th