SUBMIT Date.java (with no imports, no main(), no System calls). I\'m serious, no
ID: 3902146 • Letter: S
Question
SUBMIT Date.java (with no imports, no main(), no System calls).I'm serious, no main, no System, in what you submit, else automatic ZERO!!!!
----------------------------------------------------------------------------------------------------------------
1. Do not use any imports from the JAVA API, nor any package statements, nor System.
2. I also insist the fields of your Class must remain private access. Only three fields allowed in your Date Class (year, month, day).
3. Add a default constructor that initializes the default Date to January 1, 1970 4. Notice in the text how the toString output is always 10 characters, like 1970/01/01
5. Whenever an illegal date is attempted, your code throws an IllegalArgumentException.
6. The addDays and addWeeks methods can actually subtract days or weeks for a negative parameter passed. Test these for thousands of days too.
7. Add mutator methods (setYear, setMonth, setDay) and be certain they create valid dates, else throw the IllegalArgumentException
8. Add a longDate() method that returns a String with the format as shown below.
9. Create a static version of daysTo, used as shown in test code below. And this is the ONLY place that static appears in your Date Class.
10. Reuse: Avoid copy/paste of code (certainly no plagiarism) by using one method to call others in your Class, like only one section of "daysTo" algorithm, one general constructor called by the default, and one date verification algorithm that is used by many methods to keep the date valid.
4. Notice in the text how the toString output is always 10 characters, like 1970/01/01
5. Whenever an illegal date is attempted, your code throws an IllegalArgumentException.
6. The addDays and addWeeks methods can actually subtract days or weeks for a negative parameter passed. Test these for thousands of days too.
7. Add mutator methods (setYear, setMonth, setDay) and be certain they create valid dates, else throw the IllegalArgumentException
8. Add a longDate() method that returns a String with the format as shown below.
9. Create a static version of daysTo, used as shown in test code below. And this is the ONLY place that static appears in your Date Class.
10. Reuse: Avoid copy/paste of code (certainly no plagiarism) by using one method to call others in your Class, like only one section of "daysTo" algorithm, one general constructor called by the default, and one date verification algorithm that is used by many methods to keep the date valid.
l T-Mobile LTE 12:57 PROGRAMMING ASSIGNMENT #4 Detail Submission Grade Below is some test code, that represents onlya portion of what I might test: Assign4.java 2Relevue college CS218 W.P. Iverson instructor from Building ava Prograns text y Reges and Stepp (Pearson pub.) Programing Project 2, Chapter B, P 585 also note text examples for output fomat 8 publie class Assign4 [ Part of the main method 2'11 use to test your class // NO ?mports allowed from the JAWA API 3 public static void main(Stringt a) Date one- new Date(1582,18,1s) start of Gregecian Date two -new Date(2016,1,28):2816 was a leap year one.addDays()advance one day (negative subtracts days) one.addieeks(18): /advance one week (negative allowed, yes System.out-printin(two.daysTo(one) 17-158184 days (negative Systen,out printin(one-getDay))i day is now the 25th System.out.printin one getHonth)/ returns 12, January is Systes.out-Print1n(one-BetYear()? // still 1582 froa start System.out-printin(one-isLeapyear false for 1582 System.out printin(one.toString) style is 1582/12/2 2 3 4 try ( Date three new Date(12,34,1956): / obvlously illegal Date four # new Date(2013,2,29); // illegal leap year three.setDay (31) four.setMonth(3) four-setyear (2929) I fixes that day of month, o / fixes the month, year still wrong 7 Fixes the year, code not reached System.out.printin( Iilegal day attempted ) Use UNZX zero of 01/91/70 for default, and create longpate" output I thought a long date was dinner with a person you don 't iike Date five- new Date) System.out-printin(five.longoate)) 1 amuary 1, 197 ? // Finally, let's understand what static nethods are most commonly used for System.out-printin(Date daysTo(one, to) 1 still 158184 days (positive Dashboard Calendar To Do Notifications Inbox
Explanation / Answer
=============
Hi. please find the answer above.. i have given comments so that it is very easy for you to understand the flow. As i did n't had the test code, i could not run a flow and test. So In case of any doubts, please ask in comments.If the answer helps you, please upvote. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.