Question: XIN JAVA Math 140 Assignment 1: Due by Feb 11, 2019 11:59 pm. Assignment: Write a Java class called CalendarDate in a file named CalendarDate.java

 XIN JAVA Math 140 Assignment 1: Due by Feb 11, 2019

11:59 pm. Assignment: Write a Java class called CalendarDate in a file

XIN JAVA Math 140 Assignment 1: Due by Feb 11, 2019 11:59 pm. Assignment: Write a Java class called CalendarDate in a file named CalendarDate.java that represents a date from the Gregorian calendar Learning Outcome: Review how to write classes and create objects. Required Features Private Instance Variables. int day int month int year Public Constructor CalendarDate (int month, int day, int year)- Initializes the instance variables. If the month is below 1 then set it to 1. If the month is greater then 12 then set it to 12. If the day is a negative integer then set it to 0. If the day is greater than the number of days in the month then set it to the last day of the month. Therefore, if the year is less than The Gregorian calendar was established in 1752. 1752 then set it to 1752 Examples: new CalendarDate(13, 32, 1750) creates a CalendarDate object that represents December, 31, 1752. new CalendarDate(3, 40, 1800) creates a CalendarDate object that represents March 30, 1800. new CalendarDate(-3, -7, 1950) creates a CalendarDate object that represents January, 1, 1950. IN SAVA Math 140 Assignment 1: Due by Feb 11, 2019 11:59 pm. Public Methods int getYear()-accessor method for year . int getMonth()- acessor method for month int getDay - accessor method for day void setDate (int year, int month, int day) - resets the instance variables to the one specified by the parameters. Apply the parameters rules described in the constructor section. (This is the only mutator method for this assignment.) String getMonthAsString()- returns the month as a String value. For instance if the month 7 then the method returns "July". (Suggestion: create a local String array that contains the months of the year.) String toString()- returns a String representation of the date. month Example: If the 3, day 11, and year 2000 then return the String "March 11, 2000". . boolean equals (Object obj)-returns true if this object and the CalendarDate object stored in the parameter represent the same date. Otherwise, return false. public CalendarDate tomorrow()- returns a reference to a new CalendarDate object that represents the day after this object's day. For example, if this object is currently representing December 31, 1899 then tomorrow() will returns a reference to a CalendarDate object representing January 1, 1900. Make sure to follow the leap rules for the constructor and the tomorrow method: Years that are divisible by 4 except for the following case: If the year is divisible by 100 but it is not divisible by 400 then the year is not a leap year 2004 is divisible by 4 but it is not divisible by 100. Therefore, it is a leap Examples: year 1800 is divisible by 4 and 100. However, it is not divisible by 400. Therefore, it is not a leap year. 2400 is divisible by 4, 100, and 400. Therefore, 2400 is a leap year

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!