Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this java programming question. D Examples fr | D Intro to lava x | D Intro to Java | e Get

I need help with this java programming question.

image text in transcribed

image text in transcribed

image text in transcribed

D Examples fr | D Intro to lava x | D Intro to Java | e Get Homew X | e U/courses/2 x | O Rep n x E CW u.edu/courses/28662/assignments/395098 Community... Course Home Dashboard Consu MilLogin Login Citizenship and Im.. Dashboard MI Bri Home Lit - En Java has a built-in date class that you can use to create variables of type date, which can hold the day, month and year for a particular date. Your task for this assignment is to create your own simplifed version of the Date class, without using the builtin class. Here is the UML diagram you want to follow DateClass -int day int month int year +Date() +Date(int day, int month, int year) tisDateValid(): boolean +isEarlier(Date d): boolean + toString0:void search Fd F6 F7 F8 F10 F11 of su.edu/courses/28662/assignments/395098 -Community... Course Home Dashboard | Consu.. MilLogin - Login Citizenship and Im. Dashboard MI Bri.. C Home It essentially does the following 1. Any date can be characterized by the month day and year. These will be private attributes in your DateClass. You will also want to add getters and setters for these attributes, which are not shown here 2. Define 2 constructors, the default constructor will set the current date to 01/01/2019, the parametrized constructor will set the date to whatever argument is passed to it. 3. A toString method that prints a string representation of the date, in the "mm-dd-yyyy" format. Please format days and/or months where the value is less than 10, to print 2 digits (similar to what we did in the Time Class). 4. isDateValid) : This method will check if the current date is valid. Here are some expected outputs for this function. 02/02/2002 - Valid 13/09/2002- InValid (month cant be 12) 04/31/2012- Valid (april does not have 31 days) 02/28/2014 - InValid (february did not have 28 days in 2014, non-leap year) 02/28/2016-Valid (2016 was a leap year, so this is valid) 12/38/2016- InValid (no month has more than 31 days) To do this you may want to declare separate functions to compute if a year is a leap year or not. These functions can be private as the user of your class, does not need access to these utility functions. Likewise, you may also want to declare additional class attributes, ike an integer array containing the number of days in particular year, to help you code this functionality. Thes incorporate e are not requirements, but suggestions you should try to 5. isEarlier(Date d): boolean: Checks if another date d is earlier than the current date. For example if the current date is to search 75% F10 F11 F12 3 4 5 6 8 teValid) : This method will check if the current date is valid. Here are some expected outputs for this functic 2/02/2002-Valid 13/09/2002 - InValid (month cant be 12) 04/31/2012 - Valid (april does not have 31 days) 02/28/2014- InValid (february did not have 28 days in 2014, non-leap year) 02/28/2016 - Valid (2016 was a leap year, so this is valid) 12/38/2016- InValid (no month has more than 31 days) To do this you may want to declare separate functions to compute if a year is a leap year or not. These functions can be private as the user of your class, does not need access to these utility functions. Likewise, you may also want to declare additional class attributes, like an integer array containing the number of days in each month for a particul ar year, to help you code this functionality. These are not requirements, but suggestions you should try to incorporate. 5. isEarlier(Date d): bo 02/19/2018 and the date d holds 08/09/2018 this, should return true olean : Ch ecks if another date d is earlier than the current date. For example if the current date is 6. Write a Test Program that creates a Date object and tests out the functionality you implemented in the D Submit both .java files. 7. (ungraded) if you're curious, try to implement another function called DateDiffint d): int, which will eturn the number of days between 2 dates. This is an ungraded question, not a required component of this assignment. arch F8 F9 F10 F11 5 6 7 8 0

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

More Books

Students also viewed these Databases questions