Question: The Card superclass defines a method isExpired, which always returns false. This method is not appropriate for the driver license. Supply a method header and

The Card superclass defines a method isExpired, which always returns false. This method is not appropriate for the driver license. Supply a method header and body for DriverLicense.isExpired() that checks whether the driver license is already expired (i.e., the expiration year is less than the current year). To work with dates, you can use the methods and constants supplied in abstract class Calendar which are inherited by the concrete class GregorianCalendar. You create a Calendar as follows: GregorianCalendar calendar = new GregorianCalendar(); Then, you can obtain the current year using the constant Calendar.YEAR and method get in GregorianCalendar. The constant indicates that the method should return the current year. By comparing the returned value with the expYear field in DriverLicense, you can determine if the card is expired. The code below will retrieve the current year: calendar.get(Calendar.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!