|
1 | 1 | import javax.swing.*;
|
2 | 2 |
|
3 | 3 | public class UserRegistrationUI implements UserRegistrationUseCase{
|
4 |
| - UserDatabase database = new UserDatabase(); |
| 4 | + private UserDatabase database; |
| 5 | + |
| 6 | + public UserRegistrationUI(UserDatabase database){ |
| 7 | + this.database = database; |
| 8 | + } |
5 | 9 | void GetUserCredentials(){
|
6 | 10 | JFrame RegisterFrame = new JFrame();
|
| 11 | + RegisterFrame.setSize(1000, 1000); |
| 12 | + RegisterFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
7 | 13 | JPanel RegisterPanel = new JPanel();
|
| 14 | + RegisterFrame.add(RegisterPanel); |
| 15 | + |
| 16 | + //The textbox for entering the Username |
| 17 | + RegisterPanel.setLayout(null); |
| 18 | + JLabel usernameLabel = new JLabel("Username"); |
| 19 | + usernameLabel.setBounds(10, 25, 100, 25); |
| 20 | + |
| 21 | + JTextField usernameText = new JTextField(20); |
| 22 | + usernameText.setBounds(100, 20, 165, 25); |
| 23 | + RegisterPanel.add(usernameText); |
8 | 24 |
|
| 25 | + //The textbox for entering the password |
| 26 | + JPasswordField passwordText = new JPasswordField(); |
| 27 | + passwordText.setBounds(100, 50, 165, 25); |
| 28 | + RegisterPanel.add(passwordText); |
| 29 | + |
| 30 | + //The textbox for entering the email |
| 31 | + JLabel |
| 32 | + |
| 33 | + RegisterFrame.setVisible(true); |
9 | 34 | }
|
10 | 35 | @Override
|
11 | 36 | public void registerUser(String username, String password, String email) {
|
12 |
| - if(database.userExists(username, password, email)){ |
| 37 | + if(database.UserExists(username, email)){ |
13 | 38 | System.out.println("The username or password is already in use, please try again");
|
14 | 39 | }else{
|
15 | 40 | database.createUser(username, password, email, "Basic");
|
16 | 41 | System.out.println("Your account has been created, please verify to login");
|
17 | 42 | }
|
18 | 43 | }
|
| 44 | + |
| 45 | + public static void main(String[] args){ |
| 46 | + UserDatabase testDB = new UserDatabase(); |
| 47 | + UserRegistrationUI testUI = new UserRegistrationUI(testDB); |
| 48 | + testUI.GetUserCredentials(); |
| 49 | + } |
19 | 50 | }
|
0 commit comments