Question: Declare an interface called Incrementable which represents items that store an integer that can be incremented in some way. The interface has a method called

Declare an interface called Incrementable which represents items that store an integer that can be incremented in some way. The interface has a method called increment that increments the value and a method called getValue that returns the value. Once you have written the interface, write two classes called SequentialIncrementer and RandomIncrementer that implement the interface. The SequentialIncrementer begins its value at 0 and increases it by 1 each time it is incremented. The RandomIncrementer begins its value at random integer and changes it to a new random integer each time it is incremented.
Write a client class that creates objects of the two classes and prints out the values before calling the increment method and after calling the method. Call the increment method multiple times and print out the values.

Step by Step Solution

3.36 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!