Lab3 - Interface and Abstract Classes In the Netbeans program click on Project > New Project and save it as\"Exercise1 on your lab3 directory In this lab

Lab3 - Interface and Abstract Classes In the Netbeans...

This preview shows page 1 - 2 out of 3 pages.

Interface and Abstract Classes In the Netbeans program, click on Project > New Project and save it as "Exercise1" on your lab3 directory. In this lab, you will design and implement a class that models odometer. An odometer is a counter with a specified number of digits. There is no a priori limit on the number of digits an odometer can have. The count can be incremented or decremented by one. If all digits are 9, incrementing will cause all digits to become 0. If all digits are 0, decrementing will cause all digits to become 9. The commands an odometer must support are increment , decrement , and reset . A query count provides the current value. Design: Since there is no limit on the number of digits, we cannot use a simple integer counter. In fact, we cannot return the value of the odometer as an int . We'll return the value of the odometer as a String , with high-order 0's suppressed. The odometer is designed as a sequence of digits, each with a value in the range 0 through 9. When the odometer is incremented, if the right-most digit is less than 9, it is incremented by 1. If that digit is 9, it is set to zero and process repeated for the next digit.
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture