CS 12 - Lab 10

In this lab you are going to use class inheritance. You will need the Student class from last week's lab (but not the SSN class).

Note that the program must be written, compiled, and executed under Linux.

Changes to Student Class

First of all, make the following changes to the Student class from last week's lab:

The UCRStudent Class

Write a class called UCRStudent that maintains information about a UCR student. This class should be publicly inherited from the Student class and contain the following additional data members: The UCRStudent class should contain two constructors.

The first constructor takes no arguments and simply initializes the member data variables: the year should be set to 1, the financial status to up-to-date, and the academic probation flag to false. The other (inherited) member variables should be set to "empty" values. Note that the Student no-argument constructor does this automatically, so you do not have to add any code to do it.

The second constructor should have 6 parameters. These parameters are exactly the same as those passed to the setData method described below. This constructor should use a member initializer to initialize the inherited member data (i.e. the first name, last name, GPA, and social security number), then set the non-inherited data members (i.e. the year and financial status) from the remaining parameters.

The class should also define the following methods:

Details

Create a C++ header file, ucrstudent.h, and place your definition for the UCR student class in it. Also, create a C++ file, ucrstudent.cc, and put the implementation for the class in it.

Following are descriptions of the needed methods:

bool setData( char *fname, char *lname, double GPA, char *ssn, int year, int financial_status )
This class method is passed information needed to set the data members. To set the first name, last name, GPA, and social security number, the setData() method in the Student class should be called. If there is an error (the GPA is less than 0.0, the year is less than 0, or the financial status is not valid), the method should do nothing but return false, else it should set the data members and return true. (You can assume the parameters other than GPA, year, and financial status are always valid.)

Notice that no value is passed for the academic status. The method should call the setAcademicStatusByGPA method, after setting the GPA, to set this value. The setAcademicStatusByGPA method is described below.

void print()
This class method prints all of the information about the UCR student. Call the print method in the Student class to print the first name, last name, GPA, and social security number.

If the year is 0, the method should print that the student has graduated, else it should show the year (1, 2, etc.). For the financial and academic status, the method should print, in English, the student's status.

void setAcademicStatusByGPA()
This should be a private method that sets the academic status flag by comparing the GPA data member to 3.0. If the GPA is less than 3.0, the flag should be set to true, else it should be set to false.

There is a problem with writing this method, namely that the GPA is a private member variable of the Student class, so it can not be accessed from the UCR student class. Therefore, modify the Student class by making its private section protected instead.

Main Program

Place your main program in the file main.cc. The function should create 2 UCRStudent objects. The first should be created by calling the no-argument constructor, the second by calling the constructor that takes arguments. Note that for both UCR students, you should prompt the user for all of the information needed for the student. Make sure to print the information for both students as well.

Compiling With a Makefile

Copy your makefile from lab9 and modify it to compile your lab10 assignment.

Grading

When you have finished the program, your TA will grade it. To receive full credit, your TA will check all of the following:

Lab Grades For the Quarter

At the end of this week, the TA will be submitting your lab grades for the quarter. Therefore, you should verify that your TA has all of your scores and that they are correct. Any discrepencies should be dealt with by you and the TA prior to the TA submitting the lab grades.