CASE STUDY^675
while(moreToSearch && !found)
{
count++;
if(item == values[location])
found = true;
else
{
location++;
moreToSearch = (location < SIZE);
}
}
returnfound;
}
private voidgenerateValues(intsize)
// Initializes the values array with random integers
// from 0 to 999
{
values = new int[size];
Random rand = newRandom();
for(intindex = 0 ; index < size; index++)
values[index] = Math.abs(rand.nextInt()) % 1000 ;
}
private staticTextField inputField;
private staticLabel label;
private staticLabel outLabel;
private staticButton button;
public voidinit()
{
// Instantiate the GUI components
label = newLabel("Enter a value between 0 and 999; click Enter.");
outLabel = newLabel("Results");
button = newButton("Enter");
inputField = newTextField("Value here");
// Finish processing GUI components
button.addActionListener(this);
add(label);
add(inputField);