Guest User

Untitled

a guest
Oct 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. package Init;
  2.  
  3. /**
  4. * The abstract class Counter implements a counter that will roll over to 0
  5. * when it hits the maximum value.
  6. *
  7. * @author Anna Bieszczad <--- your name goes here
  8. * @version 08/27/2011
  9. */
  10. public abstract class Counter
  11. {
  12. // DECLARE INSTANCE VARIABLES HERE
  13.  
  14.  
  15. /**
  16. * The secondary constructor for objects of class Counter. The value and maxValue are given as parameters,
  17. * the rolledOver is false
  18. * Throws an exception if the value is greater than the maximum allowed
  19. */
  20. public Counter(int value, int maxValue) throws CounterInitializationException
  21. {
  22. // ADD CODE FOR THE CONSTRUCTOR
  23.  
  24. }
  25.  
  26. /**
  27. * Increases the value of the counter by one. Rolls over the value to 0 if needed.
  28. * Sets rolledOver boolean accordingly
  29. *
  30. * @return true if the roll over was performed
  31. */
  32. public boolean increment()
  33. {
  34. // YOUR CODE GOES HERE
  35.  
  36. return true;
  37. }
  38.  
  39. /**
  40. * Determine if two counters are in the same state
  41. *
  42. * @param other the Counter object to test against for equality
  43. * @return true if the objects are in the same state
  44. */
  45. public boolean equals(Counter other)
  46. {
  47. return true; // REPLACE WITH THE APPROPRIATE STATEMENT
  48. }
  49.  
  50. /**
  51. * Accessor to get the value of the counter
  52. *
  53. * @return the current value of the counter
  54. */
  55. public int getValue()
  56. {
  57. // CHANGE THE RETURN TO GIVE THE CURRENT VALUE OF THE COUNTER
  58. return 0;
  59. }
  60.  
  61. /**
  62. * Accessor to get the value of the counter
  63. *
  64. * @return the current value of the counter
  65. */
  66. public int getMaxValue()
  67. {
  68. // CHANGE THE RETURN TO GIVE THE MAXIMUM VALUE OF THE COUNTER
  69. return 0;
  70. }
  71.  
  72. /**
  73. * Accessor that allows the client to determine if the counter
  74. * rolled over on the last count
  75. *
  76. * @return true if the counter rolled over
  77. */
  78. public boolean getRolledOver()
  79. {
  80. // CHANGE THE RETURN TO THE ROLLOVER STATUS OF THE COUNTER
  81. return true;
  82. }
  83.  
  84. /**
  85. * Override the toString method to provide a more informative
  86. * description of the counter
  87. *
  88. * This is an abstract method. Each subclass must implement it.
  89. */
  90. public abstract String toString();
  91. }
Add Comment
Please, Sign In to add comment