Page 440 - Introduction to Programming with Java: A Problem Solving Approach
P. 440
406 Chapter 10 Arrays and ArrayLists
}
// end class SalesClerks
//***************************************************************
// Print all the data - sales clerk names and sales.
public void dumpData()
{
}
// end dumpData
}
// end findClerk
for (int i=0; i<filledElements; i++)
{
}
System.out.printf("%s: %6.2f\n",
clerks[i].getName(), clerks[i].getSales());
//***************************************************************
// Search for the given name. If found, return the index.
// Otherwise, return -1.
private int findClerk(String name)
{
for (int i=0; i<filledElements; i++)
{
Apago PDF Enhancer
if (clerks[i].getName().equals(name))
{
}
return i;
} // end for
return -1;
//***************************************************************
// Double the length of the array.
private void doubleLength()
{
}
SalesClerk[] clerks2 = new SalesClerk[2 * clerks.length];
System.arraycopy(clerks, 0, clerks2, 0, clerks.length);
clerks = clerks2;
// end doubleLength
Figure 10.22b
SalesClerks class—part B