Define a class called Counter. An object of this class is used to count things, so it records a count that is a nonnegative whole number. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current count value, as well as a method that displays the count on the screen. Do not define an input method. The only method that can set the counter is the one that sets it to zero. Write a program to test your class definition. (Hint: You need only one instance variable.)
This project requires a test program in addition to the counter class; both are straightforward
See the code in Counter.java and CounterTest.java.
Computer Science & Information Technology
You might also like to view...
Which one of the following declarations uses Pascal casing for the procedure name?
a. Sub MyProcedure() End Sub b. Sub myprocedure() End Sub c. Sub my_procedure() End Sub d. Sub myProcedure() End Sub
Computer Science & Information Technology
The Italic button is located on the ____.
A. Standard toolbar B. File tab C. Home tab D. status bar
Computer Science & Information Technology