Hi im doing a project for college and after finishing the majority of the code i hit a speedbump i need to register three types of users and one of them uses the department building nick as a basis for the password attribution i have an arraylist for each type, the password for this type of user should composed by the nick of the department and the number of registered users in that department so i wrote the code below which works which kinda works but the first password always gives me an empty field, the code i have is:
public String GivePasswordStaff(String signdept){
int counter = 0;
String password = "";
Iterator<Staff> liststaff = staff.iterator();
while (liststaff.hasNext()) {
Staff lists = liststaff.next();
if(signdept.equals(lists.getSigndept())){
counter++;
password = signdept + counter;
}
}
return password;
}
The thing is i need the first passwords of each department to be nick1 and with this code the first one is always "" and the second it gives the password i want except if i input a password for a different department in which case it always start with nick0 what can i do to solve this
Thanks in advance to all that reply