i got a Productclass stored in ArrayList myValues. I want to go trough each xth ( for example each 3th) element and have the user add some Integer values to that class.
In my for(...) he tells me: The left-hand side of an assignment must be a variable. I wonder if i messed up some of the .get(j) or if i have to synchronize my methods so that the size wont change ( there is no multi-threading but maybe thats why i get an error? ) or the solution is more simple.
Thx
public void prioPerProduct (){
System.out.println("");
System.out.println("Please enter storing and upgrading cost:");
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
int storingCost = 0;
int ruestCost = 0;
int countRes = countRessources;
int sizemyValues = myValues.size();
for(int j = 0; j < sizemyValues; j = j+countRes){
System.out.println("Please enter storingcost " + myValues.get(j).getProduct() +":" );
try {
storingCost = Integer.valueOf(br.readLine());
} catch (NumberFormatException e) {
System.out.println("No number entered");
e.printStackTrace();
} catch (IOException e) {
System.out.println("No number entered");
e.printStackTrace();
}
System.out.println("Please enter upgradingcost " + myValues.get(j).getProduct() +":" );
try {
ruestCost = Integer.valueOf(br.readLine());
} catch (NumberFormatException e) {
System.out.println("No number entered");
e.printStackTrace();
} catch (IOException e) {
System.out.println("No number entered");
e.printStackTrace();
}
myValues.get(j).setstoringCost(storingCost);
myValues.get(j).setupgradingCost(ruestCost);
}
}