Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you are to design and implement the class Date . Objects of the date class are intended to model/represent dates, where a

For this assignment you are to design and implement the class Date. Objects of the date class are intended to model/represent dates, where a date consists of a month, day and year. Each object of the Date class has a value that denotes a specific date. When viewed externally, e.g., on input and output, the values associated with a Date object consists of a 2 digit month, a 2 digit day, and a 4 digit year. Consistent with object-oriented programming conventions, it is up to you to determine the specific data members of Date class objects. Also, consistent with the object-oriented principle of encapsulation, the visibility of these data members should be specified as private. The public interface for the class, which is defined by the set of public member functions for the class must adhere to the specifications listed below.

Constructors:

Date():

This function defines a default initial date value of 00/00/0000 for a Date object.

Date(int m, int d, int y):

This function initializes a Date object to a value corresponding to the date m/d/y.

Access Functions:

int getDay() const;

Returns the day component of a Date object.

int getMonth() const;

Returns the month component of a Date object.

int getYear() const;

Returns the year component of a Date object..

bool LessThan(Date);

For two Date objects d1 and d2, d1.LessThan(d2) returns true if d1 is less than, or comes before d2.

bool GreaterThan(Date);

For two Date objects d1 and d2, d1.GreaterThan(d2) returns true if d1 is greater than, or comes after d2.

bool EqualTo(Date);

For two Date objects d1 and d2, d1.EqualTo(d2) returns true if d1 is equal to, or is the same date as d2.

Modifier Functions:

void setDay(int d);

Set the day of Date object to value specified by d.

void setMonth(int m);

Set the month of Date object to value specified by m.

void setYear(int y);

Set the year of Date object to value specified by y.

void setDate(int m, int d, int y);

Set the month, day, and year of a Date object to the values specified by m, d and y, respectively.

Input/Output Functions:

void Read();

d1.Read(); accepts from the keyboard a Date value for d1 that is input in the form mm/dd/yyyy. (This function should not provide any prompts.)

void Write();

d1.Write(); outputs to the display the value of d1 in the format mm/dd/yyyy.

(The month and day components should be output using 2 digits each, and the year should use 4 digits.)

Using this Date class you should implement an application program that prompts for and reads three date values from a user, and then outputs them in ascending date order. (There should be one prompt for each value that is to be input.) I will be supplying you with the data that you should use for your assignment submission.

In addition to your application program, I will supply a main() function to test your implementation. The output of the program that results by substituting this main() function for yours, should also be submitted.

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

Step: 3

blur-text-image

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago