Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the interface of the Date class declared in date.h Implement all the me

ID: 3620252 • Letter: C

Question

  • Complete the interface of the Date class declared in date.h
  • Implement all the member functions of Date and include them in the data.cpp file
  • Add member functions to the Person class so that the end users can access and change the birthday data member
  • Implement all the member functions declared in the Person class
  • Extend the test program (test-person.cpp) to test every member function declared in the Person class
/* Name: date.h
Copyright:
Author:
Date: 16/09/10 16:42
Description:
*/
#ifndef _DATE_H
#define _DATE_H

#include
using namespace std;

class Date{
private:
unsigned char day; //1-31
unsigned char month; //1-12
int year;
public:
Date(); //1->day, 1->month, 2010-->year
//include a list of accessors and mutators
/*********
HW3: ADD MORE MEMBER FUNCTIONS HERE
**********/
};

#endif

/////////////////
/*
Name: date.cpp
Copyright:
Author:
Date: 16/09/10 16:49
Description: implement the member functions of Date
*/

#include "date.h"

Date::Date()
{
day = 1;
month = 1;
year = 2010;
}
/*********
HW3: IMPLEMENT OTHER MEMBER FUNCTIONS HERE
**********/

/////////////////
/*
Name: person.h
Copyright:
Author:
Date: 23/02/10 18:01
Description: definition of the Person class
*/
#ifndef _PERSON_ADT_H
#define _PERSON_ADT_H

#include
#include
#include

#include "date.h"

using namespace std;

#define ID_LEN 20 //maximum length of the person ID field

const int maxNumClasses=20;

//create a new data type Person using class
class Person {
private:
string id; //identification number
string name; //the full name of a person
double height; //
double age; //
Date birthday;
int numClasses; //number of classes a person actually takes
string class_list[ maxNumClasses ];//a person can take at most 20 classes per semester
//string *email_list;//
//int num_emails; //size of *email_list

public:
Person(); //default constructor: (0, "na", -1, -1, "na"-->course_list[i])
Person(int init_id, string init_nm, double init_h, double init_age); //id0->id, name0->name, ...
void update(int init_id, string init_nm, double init_h, double init_age); //id0->id, name0->name, ...
string get_id() const; //return id
void update_id( int new_id); //new_id --> id
string get_name() const; //return name;
void update_name(string new_nm); //new_nm-->name
double get_height() const;//return height;
void update_height(double new_ht);//new_ht-->height
double get_age() const;//return age;
void update_age(double new_age); //new_age --> age

int get_numClasses(); //return numClasses;
string get_class(int i);//return class_list[ i ]
void add_class(string classname);//add classname to class_list
void change_class(int i, string newname); //if the i-th class exist, class_list[i] = newname


/*********
HW3: ADD MEMBER FUNCTIONS TO HANDLE THE birthday DATA MEMBER
**********/

//a list of member fuctions
void print() const; //print out the value of each data member
bool is_taller( const Person& someone ) const;
};

#endif //


///////////////
/*
Name: person.cpp
Copyright:
Author:
Date: 23/02/10 18:03
Description:
*/

#include "Person-adt.h"


Person::Person():id("0000"),name("na"),height(-1),age(-1)
{

/**
id = "0000";
name = "na";
height = -1;
age = -1;
**/
numClasses = 0;
for (int i=0; i
class_list[ i ] = "na";

}

Person::Person(int init_id, string init_nm, double init_h, double init_age) //id0->id, name0->name, ...)
{
char id_str[ID_LEN];
sprintf( id_str, "%04d", init_id);//convert new_id to a c-string
id = id_str;
name = init_nm;
height = init_h;
age = init_age;


}

void Person::update(int init_id, string init_nm, double init_h, double init_age)
{
char id_str[ID_LEN];
sprintf( id_str, "%04d", init_id);//convert new_id to a c-string
id = id_str;
name = init_nm;
height = init_h;
age = init_age;

if (height <= 0)
cerr << "";
}

/**/
string Person::get_id() const
{
return id;
}
/**/
void Person::update_id(int new_id)
{
char id_str[ID_LEN];
sprintf( id_str, "%04d", new_id); //convert new_id to a c-string
id = id_str;
}

string Person::get_name() const
{
return name;
}

void Person::update_name(string new_nm)
{
name= new_nm;
}

double Person::get_height() const
{
return height;
}

void Person::update_height(double new_ht)
{
height=new_ht;
}

double Person::get_age() const
{
return age;
}

void Person::update_age(double new_age)
{
age=new_age;
}

void Person::print() const
{
cout << "(id=" << id ;
cout << " name=" <
cout << " height=" << height;
cout << " age=" << age <<")"<< endl;
cout << " number of classes taken =" << numClasses <
for (int i=0; i
cout << "class " << i+1 << " :" << class_list[ i ] <
}//


bool Person::is_taller(const Person& someone) const
{
//name ="obama";
return (height > someone.height);// this ->height
}


/*********
HW3: IMPLEMENT OTHER MEMBER FUNCTIONS HERE
**********/


//////////////////////
/*
Name: test-person.cpp
Copyright:
Author:
Date: 23/02/10 18:09
Description:
*/

#include "Person-adt.h"

int main()
{
Person Kris1;

Person Kris2(111, "Kris", 6.3, 19);

Kris1.is_taller(Kris2);

Kris1.print();
//Kris2.print();

/*********
HW3: ADD MORE CODE TO TEST EVERY MEMBER FUNCTION DECLARED IN THE Person CLASS
**********/



return 0;
}//end-of-main();>;>;>;>;>
  • Complete the interface of the Date class declared in date.h
  • Implement all the member functions of Date and include them in the data.cpp file
  • Add member functions to the Person class so that the end users can access and change the birthday data member
  • Implement all the member functions declared in the Person class
  • Extend the test program (test-person.cpp) to test every member function declared in the Person class
  • Complete the interface of the Date class declared in date.h
  • Implement all the member functions of Date and include them in the data.cpp file
  • Add member functions to the Person class so that the end users can access and change the birthday data member
  • Implement all the member functions declared in the Person class
  • Extend the test program (test-person.cpp) to test every member function declared in the Person class
/*

Explanation / Answer

Dear, Date class //Header file section #include "stdafx.h" #include using namespace std; class Date { private: unsigned char day; unsigned char month; int year; public: //Constructor Date() { day=1; month=1; year=2010; } Date(char d,char m,int y) { day=d; month=m; year=y; } //Member function declarations //Mutator Functions void setDay(unsigned char ); void setMonth(unsigned char ); void setYear(int char ); //Accessor Functions unsigned char getDay(); unsigned char getMonth(); int getYear(); //Print functions to print in different formats void printFormat(); }; //Member function definitions void Date::setDay(unsigned char d) { //Input validation if(d31) { coutd; }//end if day=d; }//end setDay void Date::setMonth(unsigned char m) { //Input validation if(m12) { coutm; }//end if month=m; }//end setMonth void Date::setYear(int y) { year=y; }//end setYear unsigned char Date::getDay() { return day; }//end getDay unsigned char Date::getMonth() { return month; }//end getMonth int Date::getYear() { return year; }//end getYear void Date::printFormat() { cout