Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Init;
- /**
- * The abstract class Counter implements a counter that will roll over to 0
- * when it hits the maximum value.
- *
- * @author Anna Bieszczad <--- your name goes here
- * @version 08/27/2011
- */
- public abstract class Counter
- {
- // DECLARE INSTANCE VARIABLES HERE
- /**
- * The secondary constructor for objects of class Counter. The value and maxValue are given as parameters,
- * the rolledOver is false
- * Throws an exception if the value is greater than the maximum allowed
- */
- public Counter(int value, int maxValue) throws CounterInitializationException
- {
- // ADD CODE FOR THE CONSTRUCTOR
- }
- /**
- * Increases the value of the counter by one. Rolls over the value to 0 if needed.
- * Sets rolledOver boolean accordingly
- *
- * @return true if the roll over was performed
- */
- public boolean increment()
- {
- // YOUR CODE GOES HERE
- return true;
- }
- /**
- * Determine if two counters are in the same state
- *
- * @param other the Counter object to test against for equality
- * @return true if the objects are in the same state
- */
- public boolean equals(Counter other)
- {
- return true; // REPLACE WITH THE APPROPRIATE STATEMENT
- }
- /**
- * Accessor to get the value of the counter
- *
- * @return the current value of the counter
- */
- public int getValue()
- {
- // CHANGE THE RETURN TO GIVE THE CURRENT VALUE OF THE COUNTER
- return 0;
- }
- /**
- * Accessor to get the value of the counter
- *
- * @return the current value of the counter
- */
- public int getMaxValue()
- {
- // CHANGE THE RETURN TO GIVE THE MAXIMUM VALUE OF THE COUNTER
- return 0;
- }
- /**
- * Accessor that allows the client to determine if the counter
- * rolled over on the last count
- *
- * @return true if the counter rolled over
- */
- public boolean getRolledOver()
- {
- // CHANGE THE RETURN TO THE ROLLOVER STATUS OF THE COUNTER
- return true;
- }
- /**
- * Override the toString method to provide a more informative
- * description of the counter
- *
- * This is an abstract method. Each subclass must implement it.
- */
- public abstract String toString();
- }
Add Comment
Please, Sign In to add comment