File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 1
1
import java .io .File ;
2
2
3
3
public class UserReader {
4
- UserDatabase db = UserDatabase (accounts );
5
-
6
- public String [] UserReader (String username ) {
7
- User user = db .getUser (username );
4
+ public String [] UserReader (User user ) {
8
5
String email = user .getEmail ();
9
6
String [] out = new String [] {username , email };
10
7
return out ;
Original file line number Diff line number Diff line change 11
11
public class UserSearchUI implements UserPresenter {
12
12
private JLabel label ;
13
13
14
- // setting up access to the database of users:
15
- UserDatabase db = UserDatabase (accounts );
16
-
17
-
18
14
public UserSearchUI () {
19
15
final JFrame frame = new JFrame ();
20
16
frame .setSize (300 , 100 );
@@ -39,9 +35,12 @@ public void actionPerformed(ActionEvent e) {
39
35
// UserPresenter makes UI implement showProfile to invert the use-case --> UI dependency
40
36
@ Override
41
37
public String showProfile (String username ) {
38
+ // setting up access to the database of users:
39
+ UserDatabase db = UserDatabase (accounts );
42
40
if (db .UserExists (username )){
41
+ User user = db .getUser (username );
43
42
UserReader reader = new UserReader ();
44
- String [] features = reader .UserReader (username );
43
+ String [] features = reader .UserReader (user );
45
44
String email = features [1 ];
46
45
return ("<html>Username: " + username + "<br>Email: " + email + "</html>" );
47
46
}
You can’t perform that action at this time.
0 commit comments