Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Second part is Clear. Problem 2: The MyDate class (MyDate.java and MyDate test.java) Description: Given the following UMI write a das called My Date that

image text in transcribed
Second part is Clear. image text in transcribed
image text in transcribed
Problem 2: The MyDate class (MyDate.java and MyDate test.java) Description: Given the following UMI write a das called My Date that represents a date consisting of a year month, and day, and associated methods MyDate -year int -month: int -day:int My Date() MyDate[year.int month.int day.it getDay:int Ret Month(rint getYear): Int -addDaysday:int) vold + add Weeks week int). vold daysToother:MyDate: int isLeapYear(); boolean toString(): String . MyDate(): this non-argument Constructor will call the argument Constructor, and set the year to be 2000, month to be 1. and day to be 1. MyDate(int, int,int): this argument Constructer will create an MyDate object and set the year month and year to be a specific value .getYear();return the year value of this MyDate. get Month(); return the month value of this My Date .getDayO) return the day value of this MyDate. addDays(int days): this method will move this My Date object forward in time by the given number of days For example, if the current dates 2020/2/28. If we add it by 3 days, it will become 2020/3/2 addWeeksfint weeks): this method will move this MyDate object forward in time by the given number of seven-day weeks. For example, if the current date is 2020/3/7.if we add it by 2 weeks, it will become 2020/3/21 You can actually call the addys() method, and add it by 14 days. daysTel: this method returns the number of days that between this My Date object to the other MyDute object For example, the days from 2020/3/7 to 2020/4/1 is 25. .toStrings will return the string representation of this My Date object. For example: 2020/3/6 isleapYear(): this is to judge whether the year of this MyDate object is a leap year or not. Return true if it is a leap year, otherwise return false + Use the following criterta to judge a leap year. + If the year is divisible by 100 and at the same time also divisible by 400, it is a leap yeas. + If the year is not divisible by 100, but can be divisible by 4. i is a leap year All others are not leap year. Once the definition of the MyDute diens is done, write another Java file as MyDate_test.java, to test its methods Outputs: Sjava MyDate test Please enter the year, month, and day of a MyDate: 2020 3 6 After adding 10 days, MyDate 11 e 2a2e 16 After adding 3 weeks, MyDate will be 2820 4 7 The days between 2020/3/6 and 2820/4/5 is 19 days. 2020/376 is at a leap year. Problem 2: The MyDate class (MyDate.java and MyDate_test.java) Description: Given the following UML, write a class called MyDate that represents a date consisting of a year, month, and day, and associated methods. MyDate - year: int - month: int - day: int + MyDate() + MyDate(year:int, month:int, day:int) + getDayO:int + getMonth:int + getYear(): int + addDays(days:int): void + addWeeks(week: int): void + daysTo(other:MyDate): int + isLeap Year(): boolean + toString(): String MyDate(): this non-argument Constructor will call the argument Constructor, and set the year to be 2000, month to be 1, and day to be 1. MyDate(int, int, int): this argument Constructor will create an MyDate object, and set the year, month and year to be a specific value. .getYear(); return the year value of this MyDate. .getMonth(); return the month value of this MyDate .getDayO: return the day value of this MyDate. .addDays(int days): this method will move this MyDate object forward in time by the given number of days. For example, if the current date is 2020/2/28, if we add it by 3 days, it will become 2020/3/2 addWeeks(int weeks): this method will move this MyDate object forward in time by the given number of seven-day weeks. For example, if the current date is 2020/3/7, if we add it by 2 weeks, it will become 2020/3/21. You can actually call the addDays() method, and add it by 14 days. daysTo(): this method returns the number of days that between this MyDate object to the other MyDate object. For example, the days from 2020/3/7 to 2020/4/1 is 25. .toString(): will return the string representation of this MyDate object. For example: "2020/3/6". isLeapYear(): this is to judge whether the year of this MyDate object is a leap year or not. Return true if it is a leap year, otherwise return false. + Use the following criteria to judge a leap year: + If the year is divisible by 100 and at the same time also divisible by 400, it is a leap year. + If the year is not divisible by 100, but can be divisible by 4, it is a leap year. + All others are not leap year. Once the definition of the MyDate class is done, write another Java file as MyDate_test.java, to test its methods. Outputs: $java MyDate_test Please enter the year, month, and day of a MyDate: 2020 3 6 After adding 10 days, MyDate will be 2020 3 16 After adding 3 weeks, MyDate will be 2020 4 7 The days between 2020/3/6 and 2020/4/5 is 19 days. 2020/3/6 is at a leap year

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

What could go wrong?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago