CJCoding With Joseph
15free / daySign inCreate account

A Card class is provided. Its summary() method builds a line of text by calling two other methods of the same object, typeName() and fee(). When a subclass overrides those two methods, the inherited summary() picks up the new versions automatically, without being rewritten. Write the subclass GiftCard.

Requirements: 1. GiftCard extends Card. Its constructor takes a double balance and passes it to the Card constructor. 2. Override typeName() to return Gift. 3. Override fee(): a gift card holding 50.0 or more has no fee and returns 0.0, any smaller balance returns 1.0. The balance is private in Card, so read it with the inherited getBalance(). 4. Do not write a summary() method in GiftCard. The tests call the inherited one.

Do not change the Card class.

Do NOT write a main method.

Expected output

Basic card: balance 40.0, fee 2.5
Gift card: balance 75.0, fee 0.0

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
InheritanceClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.