CJCoding With Joseph
15free / daySign inCreate account

Report is an abstract class: every kind of report supplies its own body(), and the finished method render() wraps that body in a heading. A concrete method may call an abstract one, because the object that runs it always belongs to a subclass. Complete render().

Requirements: 1. render() returns two lines in one string, joined by \n: the heading, then the text that body() returns. 2. The heading is the title with == in front of it and == after it, so the title Sales gives == Sales ==. 3. When body() returns an empty string, the second line is (nothing to report) instead. 4. Do not add a line break after the second line.

The tests bring their own subclasses of Report. One returns a single line of text from body() and another may return an empty string. Do not change the constructor, getTitle() or the body() declaration.

Do NOT write a main method.

Expected output

== Sales ==
Units sold: 42

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

Hints4 available
Topics
Abstract ClassesClasses
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.