CJCoding With Joseph
15free / daySign inCreate account

Monotonic Odometer

The Odometer class has a private field miles. A real odometer can never run backward. Add a Miles property whose setter stores value only when it is greater than or equal to the current miles; smaller values are ignored. Do NOT write a Main method.

Setting 100 then 50 keeps the reading at (see Expected Output).

Setting 100 then 150 updates the reading to:
150

Expected Output:

100

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

Hints4 available
Topics:
Encapsulation
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.