-
Modify the Counter class so that a counter has an increment. Each time
next()
is called, the count is incremented by the increment. Add a constructor that takes as arguments the initial value and the increment. The existing constructors should initialize the increment to 1. -
Write a class called SymbolGenerator that has a single constructor with a String argument called
prefix
. Write a methodString gensym()
that generates a unique string each time it is called that consists of the prefix followed by a number that is incremented by 1 each time. So ifgensym()
is called 5 times and the prefix is "foo", it will return "foo0", "foo1", "foo2", "foo3", and "foo4".Use a Counter object to generate the numbers.
- Both the Counter class and the SymbolGenerator class will need appropriate javadoc documentation.