#include <iostream>
#include <iomanip>
#include "facultyType.h"
using namespace std;
int main()
{
cout<<fixed<<showpoint<<setprecision(2);
facultyType f1;
cout << "The following is the information in the facultyType object - f1:" << endl;
f1.print();
cout << endl;
f1.setSSN(299085146);
f1.setName("Xusheng", "Wang");
f1.setBirthDate(9, 2, 1970);
f1.setSalary(56789.23);
f1.setFullTime(true);
cout << "The following is the information in the facultyType object - f1:" << endl;
f1.print();
cout << endl;
nameType aName("Paul", "Cook");
dateType aDate(8, 12, 1981);
facultyType f2(189325619, aName, aDate, 38000.0, false);
cout << "The following is the information in the facultyType object - f2:" << endl;
f2.print();
cout << endl;
// change f2's name to "David Freeman", birth date to 02/29/1980, and full time to true
// and call .print() method to print the information in f2 again.
f2.setSSN(189325619);
f2.setName("David", "Freeman");
f2.setBirthDate( 02, 29, 1980);
f2.setSalary(38000.0);
f2.setFullTime(true);
cout << "The following is the information in the facultyType object - f2:" << endl;
f2.print();
cout << endl;
cout << "The following is the information in the facultyType object - f3:" << endl;
cout << "SSN: " << f3.SSN << endl;
cout << "Name: " << &f3.name << endl;
cout << "Birth Date: " << &f3.birthDate<< endl;
cout << "Salary: " << f3.salary << endl;
cout << "Status: " << f3.fullTime<< endl;
system("PAUSE");
return 0;
}
*****
//dataType.cpp
#include <iostream>
#include "dateType.h"
using namespace std;
void dateType::setDate(int mm, int dd, int yy)
{
year = yy; // set year
if (mm >= 1 && mm <= 12)
month = mm; // set month
else
month = 1;
if ((month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)
&& dd >= 1 && dd <= 31)
day = dd; // set day
else if ((month==4 || month==6 || month==9 || month==11) && dd >= 1 && dd <= 30)
day = dd;
else if (month==2 && year%4==0 && dd>=1 && dd<=29)
day = dd;
else if (month==2 && year%4!=0 && dd>=1 && dd<=28)
day = dd;
else
day = 1;
}
int dateType::getYear() const
{
return year;
}
int dateType::getMonth() const
{
return month;
}
int dateType::getDay() const
{
return day;
}
void dateType::print() const
{
cout << "Birth Date: ";
if (month < 10) cout << "0";
cout << month << "/";
if (day < 10) cout << "0";
cout << day << "/" << year << endl;
}
dateType::dateType(int mm, int dd, int yy)
{
setDate(mm, dd, yy);
***
//dataType.h
#ifndef H_dateType
#define H_dateType
#include <string>
using namespace std;
class dateType
{
public:
void setDate(int, int, int);
int getYear() const;
int getMonth() const;
int getDay() const;
void print() const;
dateType();
dateType(int mm=1, int dd=1, int yy=2000);
int month;
int day;
int year;
};
#endif
*************
//facultyType.cpp
#include <iostream>
#include <cstring>
#include "nameType.h"
using namespace std;
void nameType::setName(char first[], char last[])
{
strcpy(firstName, first); // set the first name
strcpy(lastName, last); // set the last name
}
void nameType::getName(char first[], char last[]) const
{
strcpy(first, firstName); // get the first name
strcpy(last, lastName); // get the last name
}
void nameType::print() const // print the name
{
cout << "Name: " << firstName << " " << lastName << endl;
}
nameType::nameType() // default constructor
{
firstName[0] = '\0'; // set the first name to null string
lastName[0] = '\0'; // set the second name to null string
}
nameType::nameType(char first[], char last[]) // a constructor
{
setName(first, last); // set the name
}
*****
//nameType.h
#ifndef H_nameType
#define H_nameType
class nameType
{
public:
void setName(char [], char []); // set the full name
void getName(char [], char []) const; // get the full name
void print() const; // print the name
nameType(); // default constructor
nameType(char [], char []); // a constructor with parameters
private:
char firstName[30]; // store the first name
char lastName[30]; // store the last name
};
#endif
****
//personType.cpp
#include <iostream>
#include "personType.h"
#include <cstring>
#include "nameType.h"
#include "dateType.h"
using namespace std;
// Add your implement code for personType below
void personType::setSSN(long ssn)// set the SSN
{
SSN = ssn;
}
long personType::getSSN(long& s) const// get the SSN
{
return SSN;
}
void personType::setName(char first [], char last[]) // set the name
{
}
void personType::setName(nameType&) // set the name
{}
nameType getName()
{}
void personType::setBirthDate(int m, int d, int y) // set the birthDate
{}
void personType::setBirthDate(dateType&) // set the birthDate
{}
dateType getBirthDate()
{}
void personType::print() const
{
cout << "SSN: " << SSN << endl;
cout << "Name: " << &name << endl;
cout << "Birth Date: " << &birthDate << endl;
long getSSN(long& ) const; // get the SSN
void setName(char first [], char last[]); // set the name
void setName(nameType&); // set the name
nameType getName() const;
void setBirthDate(int m, int d, int y);
void setBirthDate(dateType&);
dateType getBirthDate() const;
void print() const;
personType(); // default constructor
personType(long, nameType&, dateType&);
And? You haven't asked a question, told us what your problem is, or even given us the slightest indication of what you're trying to achieve. What are we supposed to do with this post?
And if you're going to post code, please use code tags to make it readable: