Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java class CustomDate that represents a calendar date consisting of a month, day, and year. Use three data fields of type int to

Write a Java class CustomDate that represents a calendar date consisting of a month, day, and year. Use three data fields of type int to represent the date. For example, July 4, 1776, is month 7, day 4, and year 1776. There should be no other instance variables other than these three integer values.

  • Write 1 default and 2 parameterized constructors the default date should be set to January 1, 1900.
  • The first parameterized constructor: public CustomDate(int newMonth, int newDay, int newYear) to accept month int
  • The second parameterized constructor: public CustomDate(String newMonth, int newDay, int newYear) to convert string month to int
  • Setter methods (setDay, setMonth, setYear) with one argument to change the day month or year (the month setter is overloaded one setter to accept an integer value and the other to accept a String representing the month);
  • Getter methods (getDay, getMonth, getYear) that return the day, month, or year as an int;
  • A toString method (public String toString()).
  • In addition, provide methods that
  • Determine whether the current year is a leap year (public boolean isLeapYear())
  • Advance the current date by one day (public void advanceOneDay())
  • Advance the current date by one week (public void advanceOneWeek())
  • Override the equals method from Object (public boolean equals(Object obj))
  • Compares this CustomDate object with the object passed as a parameter for chronological order and returns a negative integer, zero, or a positive integer, if this object is less than, equal to, or greater than the specified object. (public int compareTo (CustomDate obj) )

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions