Hi i am writing a program for a Plant
the machine has a containers per min production rate
containers are 500grams
and each storage area has a capacity that stores the products that the machine makes.
So, for t his method i have to find out how much space is left in all storage area
getAvailableStorage
public int getAvailableStorage()
Gets the total room available in all storage areas by iterating through all storage areas and adding the available room in each.
Returns:
Total available room in all storage areas.
so for example
a plant has
storage area 1 capacity = 15000
storage area 2 capacity = 2500
storage area 3 capacity = 3000
Total = 20500
machines are stored in the plant
so i have 3 machines
machine 1 = 30perMin = 30x500 = 15000
machine 2 = 5perMin = 2500
machine 3 = 5perMin = 2500
Total = 20000
get Available Storage should output 500 space left
old code :
int availableStorage;
for (StorageArea getStorage: arealocation){
storageSpace += getStorage.getCapacity();
}
availableStorage = storageSpace - total;
return availableStorage;
}
my old code outputs 500 space left, but this is not what he's asking for he wants me to iterate trhough all storage areas, and add avaiable room in each
so machine 1 produce 30 containers a min which is 15000, so storage area 1 is filled
storage 2 is also filled
storage area 3 has 500 space left
how would i iterate through allt he storage area and add how much rooms are left in each?
so that
index 0 has 0 space left
index 1 has 0 space left
index 2 has 500 space left
Edited by turbonerds - 4/8/12 at 2:04pm
the machine has a containers per min production rate
containers are 500grams
and each storage area has a capacity that stores the products that the machine makes.
So, for t his method i have to find out how much space is left in all storage area
getAvailableStorage
public int getAvailableStorage()
Gets the total room available in all storage areas by iterating through all storage areas and adding the available room in each.
Returns:
Total available room in all storage areas.
so for example
a plant has
storage area 1 capacity = 15000
storage area 2 capacity = 2500
storage area 3 capacity = 3000
Total = 20500
machines are stored in the plant
so i have 3 machines
machine 1 = 30perMin = 30x500 = 15000
machine 2 = 5perMin = 2500
machine 3 = 5perMin = 2500
Total = 20000
get Available Storage should output 500 space left
old code :
int availableStorage;
for (StorageArea getStorage: arealocation){
storageSpace += getStorage.getCapacity();
}
availableStorage = storageSpace - total;
return availableStorage;
}
my old code outputs 500 space left, but this is not what he's asking for he wants me to iterate trhough all storage areas, and add avaiable room in each
so machine 1 produce 30 containers a min which is 15000, so storage area 1 is filled
storage 2 is also filled
storage area 3 has 500 space left
how would i iterate through allt he storage area and add how much rooms are left in each?
so that
index 0 has 0 space left
index 1 has 0 space left
index 2 has 500 space left
Edited by turbonerds - 4/8/12 at 2:04pm





{