forked from CSnakeEyes/RegistrationSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrar.java
More file actions
40 lines (37 loc) · 1 KB
/
Registrar.java
File metadata and controls
40 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
public class Registrar extends User{
public Registrar(String firstName, String lastName, String userName, String password, Set<Registrar> allRegistrars){
Random rand = new Random();
boolean uniqueLoop = true;
int tries = 0;
int tempId =-1;
while(uniqueLoop && tries < 100){
tempId = rand.nextInt((86666666 - 83333333) + 1) + 83333333;
boolean match = false;
tries++;
Iterator<Registrar> it = allRegistrars.iterator();
while(it.hasNext()){
Registrar current = it.next();
if(current.firstName == firstName && current.lastName == lastName){
setID(-1);
return;
}
if(current.getID() == tempId)
match = true;
if(match)
uniqueLoop = true;
else
uniqueLoop = false;
}
}
setID(tempId);
this.firstName = firstName;
this.lastName = lastName;
setUserName(userName);
setPassword(password);
}
public void addNewCourse(){
}
}