This part of the programming project may be done individually or in groups of two. Keep in mind that you may not work with the same person on more than two of the programming projects. If you work with a teammate, hand in one copy of your code with both names on it. It is okay to get help from the TAs and/or the instructor if you get stuck, but you should try to do it on your own first.
The purpose of this assignment is to enhance the Histogram program from the Histogram Lab. Remember to test your program after every step.
Final Location | Index | |
---|---|---|
SimpleGrid
,
TextCell
, and ColorBlock
) is a
ValidatedInputReader
class that will allow you to
prompt the user for the number of iterations to
use for the simulation.
One of the methods in this class is a static
getInteger
method that takes five parameters: the initial
prompt string, the minimum number that is valid, the maximum
number that is valid, a suggested value,
and the clarification prompt. Because the method is
static
, it is tied to the class rather
than to a specific object or instance of the class. In other
words, you can call this method without constructing an instance
of the class, as follows:
int numIterations =
ValidatedInputReader.getInteger("prompt", min_val,
max_val, suggested_val, "prompt2");
You may
use the constant Integer.MAX_VALUE
to represent the
largest number that is acceptable. (You can read the full class
documentation for the ValidatedInputReader
class
here.)
Once you have prompted the
user for the number of iterations, change your program so that it
uses this number to control the number of iterations that the
simulation runs. Then remove the
NUM_ITERATION
constant. Test it with different
numbers of iterations, including zero and one or more negative
numbers.
YourName_Hist_PP
, zip it,
and submit it to
Kit as a single zip file.