Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Card superclass defines a method isExpired, which always returns false. This

ID: 3695396 • Letter: T

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 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)

Explanation / Answer

The ID card and the calling card don't expire. What should you do to reflect this fact in your implementation?

Add a method getExpiredCardCount, which counts the number of expired cards in the billfold.

billfold class:

To populates a billfold with a phone card and an expired driver license with CardDriver class