I currently am working on a simplified inventory program where I have objects called Items (each have a name, rating, and price) that are stored in Item arrays called Rack, and racks are stored in 2d Rack arrays called warehouseRacks. I need to get the price of the all the items and sum them up.
public double totalAssets(){
double sum = 0.0;
for (int i=0; i<warehouseRacks.length; i++){
for (int j=0; j<warehouseRacks[i].length; j++){
Rack racks = warehouseRacks[i][j];
Item[] item = racks[i].getItem();
sum = sum + thing[j].getPrice();
}
}
return sum;
}
I'm having trouble indexing into all of the arrays to get out actual Item object, so I either get errors like the following, or null pointer exceptions.
I'm currently getting this error: Warehouse.java:57: error: array required, but Rack found Item[] thing = racks[i].getItem();
What am I missing that's keeping it from getting out the Item?
*I'm new to Java and have been working with OOP concepts for a week or so!