Well, I was going to call it a day and just relax for the rest of the weekend, but Peter got me all fired up, so before I shut her down I decided to throw one more twist. Wouldn't it be clever to keep a running total of the values? I thought. I currently display the value of each cd depending on how many are in stock and its price.
How hard could it be to just sum that field. Apparently harder than I though. Here is what I came up with: Value being the name of the parameter already used, and cdCount being my counter.
public static float calculateTotal(Inventory completeValue[]);
float totalValue = 0;
for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
{
totalValue += completeValue[cdCount].getValue();
} // end for
return totalValue;
I just inserted that at the bottom of my Compactdisk class, right after the brace that closes return(price * nstock);, but before the one that ends the class.
I get
Compactdisk.java:79: illegal start of type
for ( int cdCount = 0; cdCount < completeValue.length; cdCount++ )
^
Compactdisk.java:83: <identifier> expected
return totalValue;
I thought this would be simple, can anyone see what I am missing? It almost looks to me as if it does not like the method there at all.