====== Programming Lab Exercise ======
* Topics: Implementing Classes
==== Counter.java, TestCounter.java ====
{{http://mitrees.com/image/cache/data/catalog/GS/53029_TallyCounter-500x500.jpg?100}}
In DrJava, define a class called //Counter// in //Counter.java//.
An object of this class is used to count things, so it records a count that is a non-negative whole number.
In the //Counter// class, include methods to set the counter to 0 (reset), to increase the count by 1, and to decrease the count by 1. Also include an accessor method that returns the current count value, as well as a method that displays the count using //System.out.println//.
__Notes:__
Use the "private" access modifier for the Counter class instance variable.
Use these names for the Counter class methods:
resetCount - set the counter to 0
increaseCount - to increase the count by 1
decreaseCount - to decrease the count by 1
getCount - accessor method that *returns* the current count value
showCount - method that displays the value of the count
In //TestCounter.java// do the following:
- Declare a Counter class object variable called mycount.
- Reset mycount.
- Increase mycount 3 times.
- Show mycount. (Output should be: "Current value of count is 3")
- Decrease mycount 4 times.
- Show mycount. (Output should be: "Current value of count is -1")
- Reset mycount again.
- Show mycount. (Output should be: "Current value of count is 0")
Links to source code: [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i0hcxk99dun2z2|Counter.java]], [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i0hcxnipdmk30f|TestCounter.java]]
----