#include "student.h" #include #include using namespace std; void Student::Initialize(string n) { name = n; GPA = 0.0; num_classes = 0; cout << name << " is alive" << endl; } Student::Student(int max_speed, string mm, string n) { vehicle = new Car(max_speed, mm); Initialize(n); } Student::Student(string n) { vehicle = new Car; Initialize(n); } Student::~Student() { delete vehicle; cout << name << " is going away" << endl; } double Student::LG2NG(char lg) { switch (toupper(lg)) { case 'A' : return 4.0; case 'B' : return 3.0; case 'C' : return 2.0; case 'D' : return 1.0; default : return 0.0; } } void Student::TakeClass() { char lg; cout << "What did you get (A-F)? "; cin >> lg; GPA = (GPA * num_classes + LG2NG(lg)) / ++num_classes; cout << endl << "New GPA = " << GPA << " (" << num_classes << ")" << endl; } void Student::GoToSchool() { vehicle->Accelerate(60); vehicle->Drive(); vehicle->Decelerate(60); }