8
8
9
9
public class UserRegistrationUI implements UserRegistrationUseCase , ActionListener {
10
10
private final UserDatabase database ;
11
-
11
+ private JLabel registrationSuccess ;
12
12
private JTextField usernameText ;
13
13
private JTextField passwordText ;
14
14
private JTextField emailText ;
@@ -18,12 +18,16 @@ public class UserRegistrationUI implements UserRegistrationUseCase, ActionListen
18
18
19
19
public UserRegistrationUI (UserDatabase database ) {
20
20
this .database = database ;
21
- code = new Random ().nextInt (1244254 );
21
+ /*TODO: For now the code is 389 for testing purposes, but once UserVerificationUI.sendVerificationCode() is
22
+ implemented this will be a random integer.
23
+ */
24
+ /*code = new Random().nextInt(1244254);*/
25
+ code = 389 ;
22
26
}
23
27
void GetUserCredentials (){
24
28
//Front end related objects
25
29
JFrame registerFrame = new JFrame ();
26
- registerFrame .setSize (300 , 300 );
30
+ registerFrame .setSize (500 , 300 );
27
31
registerFrame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
28
32
JPanel registerPanel = new JPanel ();
29
33
registerFrame .add (registerPanel );
@@ -62,25 +66,26 @@ void GetUserCredentials(){
62
66
register .addActionListener (this );
63
67
registerPanel .add (register );
64
68
65
-
69
+ //Success/Failure Label
70
+ registrationSuccess = new JLabel ("" );
71
+ registrationSuccess .setBounds (10 , 140 , 350 , 25 );
72
+ registerPanel .add (registrationSuccess );
66
73
67
74
registerFrame .setVisible (true );
68
75
}
69
76
@ Override
70
77
public void registerUser (String username , String password , String email ) {
71
78
if (database .UserExists (username , email )){
72
- //Will change below to be a label
73
- System .out .println ("The username or password is already in use, please try again" );
79
+ registrationSuccess .setText ("The username or password is already in use, please try again" );
74
80
}else {
75
81
database .createUser (username , password , email , "Basic" );
76
- //Will change below to be a label
77
- System .out .println ("Your account has been created, please verify to login" );
82
+ registrationSuccess .setText ("Your account has been created, please verify to login" );
78
83
UserVerificationUI verifyUser = new UserVerificationUI (code );
79
84
verifyUser .sendVerificationCode (email );
80
85
verifyUser .verify (email );
81
86
}
82
87
}
83
-
88
+ //For Testing purposes
84
89
public static void main (String [] args ){
85
90
UserDatabase testDB = new UserDatabase (new File ("TestUserDatabase2.csv" ));
86
91
System .
out .
println (
testDB .
UserExists (
"RandomUser" ,
"[email protected] " ));
0 commit comments