Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the date class interface below: class date { public: void setDate(int mm, int dd, int yyyy); // Postcondition : data object has been set

Given the date class interface below:

class date

{

public:

void setDate(int mm, int dd, int yyyy);

// Postcondition: data object has been set to the values passed to the function

int getMonth();

// "accessor function" or simply "accessor"

// Postcondition: month of the calling object is returned

int getDay();

// Postcondition: day of the calling object is returned

int getYear();

// Postcondition: year of the calling object is returned

int difference(date &d2);

// Postcondition: number of days between the calling date object and date object d2 passed to the function

int compareDates(date &d2);

// Comparing the calling date object and the date object d2 passed to the function

// Postcondition: returns 1, 0, and -1 if the calling object is earlier than, later than, or the same as the object d2, respectively

void inputDate();

// Prompts the user to enter three integer values for month, day, and year

// Postcondition: the calling object is filled with valus entered by the user

void displayDate();

// Postcondition: the contents of the calling object is displayed in mm/dd/yyyy format

private:

bool isLeapYear();

// A "helper" or "auxiliary" function called by public member function(s); not accessible from outside of the class

// Postcondition: returns true if the "year" of the calling object is a leap year; returns false otherwise

int month;

int day;

int year;

};

You are asked to

  1. implement all nine member functions of the above date class.
  2. Write a main() function to test all nine member functions directly or indirectly. Design your program output to make it clearly and easily readable to anyone who reads it. The output of a sample run tests most by not all member functions but you should test them all. Note that the isLeapYear() is indirectly called by the difference() function.

Note: If you have trouble with the coding of difference() member function, you may ignore the isLeapYear() member function and make a simple assumption that all twelve months contains 30 days.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions