Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Program (The MyDate class) Design a class named MyDate. The class contains: The data fields year , month , and day that represent

In C++ Program

(The MyDate class) Design a class named MyDate. The class contains:

The data fields year , month , and day that represent a date. month is 0-based, i.e., 0 is for January.

A no-arg constructor that creates a MyDate object for the current date.

A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in seconds.

A constructor that constructs a MyDate object with the specified year, month, and day.

Three constant getter methods for the data fields year , month , and day , respectively.

Three setter methods for the data fields year , month , and day , respectively.

Write a method that checks whether a given year is a leap year.

The subtract 365 from the number of days in step 3 if the year was not a leap year. Otherwise, subtract 366 from the number of days in step 3.

After you sequentially subtract 365 and 366, you 'll stop when your number is between 1 and 366 (inclusive). During this process, also update the year.

From there, you are going to subtract 28, 29 (depends on the leap year), 30, or 31 to obtain the month and the day. Make sure to plus 1 to obtain the correct day; You'll stop when your number is between 1 and 31 (inclusively).

A function named setDate(long elapsedTime) that sets a new date for the object using the elapsed time.

Write a test program that creates two MyDate objects (using new MyDate() and new MyDate(34355555133101L)) and displays their year, month, and day. (Hint: The first two constructors will extract the year, month, and day from the elapsed time.

For example, if the elapsed time is 561555550000 milliseconds, the year is 1987, the month is 9, and the day is 18.)

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions