J
jcastile
I am having problems with this section of code...
public void updateRank(){
int x = -1;
int y = -1;
String winnerMemNum = JOptionPane.showInputDialog
("Enter winner's membership number:");
int wMemNum = Integer.parseInt(winnerMemNum);
for(int i=0;i<list.size();i++){
Player temp = (Player)list.get(i);
if(temp.getMemberNumber() == wMemNum)
x = i;
else
System.out.println("Player not found");
break;
}
I want the condition in the if statement to be tested for every element
in the list before the code in the else block executes, but at the
moment it is only testing the first element. I know I need to put
brackets in, but when I did that, the whole thing stopped working! Any
ideas?
public void updateRank(){
int x = -1;
int y = -1;
String winnerMemNum = JOptionPane.showInputDialog
("Enter winner's membership number:");
int wMemNum = Integer.parseInt(winnerMemNum);
for(int i=0;i<list.size();i++){
Player temp = (Player)list.get(i);
if(temp.getMemberNumber() == wMemNum)
x = i;
else
System.out.println("Player not found");
break;
}
I want the condition in the if statement to be tested for every element
in the list before the code in the else block executes, but at the
moment it is only testing the first element. I know I need to put
brackets in, but when I did that, the whole thing stopped working! Any
ideas?