โ Back to Encapsulation
Question 492
Monotonic Odometer
Monotonic Odometer
TheOdometerclass has a private fieldmiles. A real odometer can never run backward. Add aMilesproperty whose setter storesvalueonly when it is greater than or equal to the currentmiles; smaller values are ignored. Do NOT write aMainmethod. Setting 100 then 50 keeps the reading at: 100 Setting 100 then 150 updates the reading to: 150
Expected Output:
100
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท 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.