← Back to Classes
Question 120
SeniorPass Subclass
SeniorPass Subclass
Consider the TransitPass and StudentPass classes shown below. Define a subclass called SeniorPass that extends TransitPass. Requirements: 1. Create a constructor that usessuper()to set the base fare. 2. Seniors ride free, so the senior rate should be 0.0. 3. OverridecalcFare()to use the senior rate. 4. OverridetoString()to return: "Senior Pass:<rate>". Do NOT write a main method. A hidden Main will test your class. TransitPass and StudentPass are provided in the tests.
Expected Output:
3.0 0.0 Senior Pass: 0.0
= newline. The output ends with a newline — print one after the last line.
Hints3 available
Sign in to use hintsTopics:
Classes
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.