CJCoding With Joseph
15free / daySign inCreate account

A Room class is provided. Write the subclass Suite, a room with extra beds that cost more per night.

Requirements: 1. Suite extends Room and adds one private field, int extraBeds. 2. The constructor takes number, nightlyRate and extraBeds, in that order. It passes the first two to the Room constructor and keeps the third. 3. Override cost(int nights): the result is the parent's cost for those nights plus 15.0 for each extra bed for each night. Get the parent's part with super.cost(nights), because nightlyRate is private in Room. 4. Add describe(), which returns text in the form Suite 12 with 2 extra beds. The room number is private in Room, so read it with the inherited getNumber().

Do not change the Room class.

Do NOT write a main method.

Expected output

12
130.0
390.0
Suite 12 with 2 extra beds

= 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.