Write a class called Date that represents a date consisting of a year, month, and day. A Date object should have the following methods: public Date(int year, int month, int day) Constructs a new Date object to represent the given date. public void addDays(int days) Moves this Date object forward in time by the given number of days. public void addWeeks(int weeks) Moves this Date object forward in time by the given number of seven-day weeks. public int daysTo(IDate other) Returns the number of days that this Date must be adjusted to make it equal to the given other Date. public int getDay() Returns the day value of this date; for example, for the date 2006/07/22, returns 22. public int getMonth() Returns the month value of this date; for example, for the date 2006/07/22, returns 7. public int getYear() Returns the year value of this date; for example, for the date 2006/07/22, returns 2006. public boolean isLeapYear() Returns true if the year of this date is a leap year. A leap year occurs every four years, except for multiples of 100 that are not multiples of 400. For example, 1956, 1844, 1600, and 2000 are leap years, but 1983, 2002, 1700, and 1900 are not. public String toString() Returns a String representation of this date in year/month/day order, such as "2006/07/22".

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Write a class called Date that represents a date consisting of a year, month, and day. A Date object should have the
following methods:
public Date(int year, int month, int day)
Constructs a new Date object to represent the given date.
public void addDays(int days)
Moves this Date object forward in time by the given number of days.
public void addWeeks(int weeks)
Moves this Date object forward in time by the given number of seven-day weeks.

public int daysTo(IDate other)
Returns the number of days that this Date must be adjusted to make it equal to the given other Date.
public int getDay()
Returns the day value of this date; for example, for the date 2006/07/22, returns 22.
public int getMonth()
Returns the month value of this date; for example, for the date 2006/07/22, returns 7.
public int getYear()
Returns the year value of this date; for example, for the date 2006/07/22, returns 2006.
public boolean isLeapYear()

Returns true if the year of this date is a leap year. A leap year occurs every four years, except for multiples of 100
that are not multiples of 400. For example, 1956, 1844, 1600, and 2000 are leap years, but 1983, 2002, 1700, and
1900 are not.
public String toString()
Returns a String representation of this date in year/month/day order, such as "2006/07/22".

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage