Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create, test, and document a Java class using the adapter pattern to implement the following interface. /** * DateInterface contains a set of methods to

Create, test, and document a Java class using the adapter pattern to implement the following interface.

/** * DateInterface contains a set of methods to manipulate dates. Similar to some of * *the methods in the class java.util.Date. */ public interface DateInterface { /** * returns the year * @return the year stored by the object */ public int getYear(); /** * sets the year * @param year * @return true */ public boolean setYear(int year); /** * Returns the month: 0 for January, 1 for February, etc., and 11 for December. * @return integer corresponding to the month */ public int getMonth(); /** * Sets the month, provide it is between 0 and 11; otherwise no changes are made. * month must be consistent with the year and day of month. For example, if month * is 1 (Februray), but year is 2016 and day of month is 30 as stored in the DateInterface * object, the month stored in the DateInterface object must not be changed. The client * must do some extra work to effect the change: for example, change the day to 1 and then change * month Anther example is changing month to 3 (April) when day of month is 31. * @param month should be between 0 and 11 * @return returns true if month is valid and a change could be made */ public boolean setMonth(int month); /** * returns the day * @return day of the month */ public int getDayOfTheMonth(); /** * sets the day of the month. should be a valid day or no action is taken. * For example, if you set 29 for February and the year 1900 as stored in the * DateInterface object, the change will not be made. Essentially, the change in * day of month must not potentially be an inconsistent date: for example, change the * month to 11 and then change month. * @param date a valid date and year * @return true only if the day is valid and change could be made */ public boolean setDayOfMonth(int date); /** * returns the hour between 0 and 23 * eturn the hour in military time */ public int getHours(); /** * returns the hour. should be between 0 and 23 or no action is taken * @param minuted 0-23 * @return true only if hours is valid and a change could be made */ public boolean setHours(int hours); /** * returns the number of minutes pat the hour * @return number of minutes past the hour */ public int getMinutes(); /** * sets the minuted of this object; should be between o and 59 or no changes are made * @param minuted 0-59 * @return true only if hours is valid and a change could be made */ public boolean setMinutes(int minuted); /** * returns the number of seconds past the minute * @retun the number of seconds past the minute */ public int getSeconds(); /** * sets the second of this object; should be between 0 and 59 or no changed are made * @param secons 0-59 * @return true if seconds is valid and a change could be made */ public boolean setSeconds(int seconds); /** * returns true if and only if the year is a leap year * @return true if and only if the year is a leap year */ public boolean isLeapYear(); } Your task is to implement the above interface using the Adapter pattern. For this, use the GregorianCalendar class. The implementation must be called DateImpl. When the object is created, it must be set to the current date and time.

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

Question

14-18 Compare the two major types of planning and control tools.

Answered: 1 week ago