Classes and constructors

Can someone help me I am stuck. My task is to use the given main.cpp and student.h file to create a student.cpp file that will use the class Student and variables to show the output of:
Your output will look like this if the class is implemented correctly…
Your output will look like this if the class is implemented correctly…
Student, Homer Simpson ("Freshman"):
ID: 1
Major: Undeclared
Current Units: 0
Total Units: 0
Student, Lisa Simpson ("Junior"):
ID: 2
Major: Undeclared
Current Units: 0
Total Units: 88
Student, Bart Simpson ("Sophomore"):
ID: 3
Major: Electrical Engineering
Current Units: 0
Total Units: 40


Homer Simpson is taking 12 units this semester.
Semester completed, Homer Simpson (Freshman) now has 12 units towards his degree.
Homer Simpson is taking 21 units this semester.
Semester completed, Homer Simpson (Sophomore) now has 33 units towards his degree.
Homer Simpson has changed his major:
FROM: Undeclared
TO: Mechanical Engineering
Error found in Homer Simpson (ID: 1), total units = 89 Junior Class

This is what I have so far:
student.cpp
#include "student.h"
#include <iostream>


using namespace std;



Student::Student(string fn, string ln)
{
studentId=1;
fname=fn;
lname=ln;
unitsThisSemester=0;
totalUnits = 0;
major="Undeclared";

}

Student::Student(string fn, string ln, double x)
{
studentId=2;
fname=fn;
lname=ln;
totalUnits=x;
major="Undeclared";
unitsThisSemester=0;
}
Student::Student(string fn, string ln,string m, double x)
{
studentId=3;
fname=fn;
lname= ln;
major= m;
totalUnits=x;
unitsThisSemester=0;
}

void Student::updateTotalUnits(double u)
{
units=u;
}
void Student:: completeSemester();
{

}






void Student::printStudent()
{
cout<< "Student,: "<< fname << lname<<endl;
cout<< "ID:"<< studentId<<endl;
cout<< "Major:"<< major<< endl;
cout<< "Current units:" << unitsThisSemester<< endl;
cout<< "Total units:" << totalUnits<< endl;

}


main.cpp
#include <iostream>
#include <string>
#include "student.h"

using namespace std;

int main()
{

Student s1("Homer", "Simpson");


s1.printStudent();

Student s2("Lisa", "Simpson",88.0);
s2.printStudent();

Student s3("Bart", "Simpson", "Electrical Engineering", 40.0);
s3.printStudent();
//
// now check assessors, mutators...
//
cout << endl << endl;

s1.updateSemesterUnits(12);

cout << s1.getStudentName() << " is taking " << s1.getStudentCurrentUnits() << " units this semester." << endl;

s1.completeSemester();

cout << "Semester completed, " << s1.getStudentName() << " (" << s1.getStudentClass() << ") now has " << s1.getStudentTotalUnits() << " units towards his degree." << endl;

s1.updateSemesterUnits(21);

cout << s1.getStudentName() << " is taking " << s1.getStudentCurrentUnits() << " units this semester." << endl;
s1.completeSemester();

cout << "Semester completed, " << s1.getStudentName() << " (" << s1.getStudentClass() << ") now has " << s1.getStudentTotalUnits() << " units towards his degree." << endl;

cout << s1.getStudentName() << " has changed his major: " << endl;

string oldMajor = s1.getStudentMajor();

s1.updateMajor("Mechanical Engineering");

string newMajor = s1.getStudentMajor();



cout << "\tFROM: " << oldMajor << endl << "\tTO: " << newMajor << endl;

s1.updateTotalUnits(89);
cout << "Error found in " << s1.getStudentName() << " (ID: " << s1.getStudentID() << "), total units = " << s1.getStudentTotalUnits() << " " << s1.getStudentClass() << " Class " << endl;


return 0;
}

student.h
#ifndef STUDENT_H
#define STUDENT_H

#include <iostream>

using namespace std;

class Student
{
public:
/*

Constructors...
Note: There is no default constructor for Student, it wouldn't make sense in
this implementation.

*/
Student(string fname, string lname, string major, double totalUnits);
Student(string fname, string lname, double totalUnits);
Student(string fname, string lname);
/*

Mutators...

Update the sudent's total units with param 'units' and update student
class standing accordingly (Freshman...Senior)
*/
void updateTotalUnits(double units);
/*
Update the sudent's semester units with param 'units'
*/
void updateSemesterUnits(double units);
/*
Complete the semester...
Update the sudent's total units with student's semester units,
clear out student's semester units, update student's class standing.
*/
void completeSemester();
/*
Update the sudent's major with param 'newMajor'
*/
void updateMajor(string newMajor);
/*

Assessors...

Returns the student's total units
*/
double getStudentTotalUnits() const;
/*
Returns the student's current units taken in the semester
*/
double getStudentCurrentUnits() const;
/*
Returns the student's name
*/
string getStudentName() const;
/*
Returns the student's major
*/
string getStudentMajor() const;
/*
Returns the student's class standing
*/
string getStudentClass() const;
/*
Returns the student's ID
*/
int getStudentID() const;
/*
Prints out the student's record
*/
void printStudent() const;
/*
destructor...
*/
~Student();


private:
int studentId;
string major;
string fname;
string lname;
string whatClass;
double unitsThisSemester;
double totalUnits;
static int lastID; // this is the last ID in use. This variable is 'shared' between all objects; i.e., there
// is only 1 copy of lastID for all students;
/*
Private mutators only for execution WITHIN THE CLASS; i.e., these are NOT
visible to the outside, nor are they 'callable'...

Returns the next available student ID that isn't being used.
NOTE: this mutator is in the 'private' section as no one should
be calling this routine from the outside.
*/
int getID();
/*
Returns the students class level: Freshman, Sophomore, Junior, Senior depending
on a 30 credit class level; i.e., 0-29 is a Freshman, 30-59 is a Sophomore,
60-89 is a Junior, and > 90 is a Senior.

Note:this routine is called whenever the student's totalUnits are updated.
*/
string setClass(double units);

};

int Student::getID()
{
int id = lastID;
lastID++;
return id;
}

int Student::lastID = 1; // set the 'shared' variable to 1 to begin with

#endif


Any help would be appreciated
Topic archived. No new replies allowed.