File tree Expand file tree Collapse file tree 5 files changed +31
-21
lines changed Expand file tree Collapse file tree 5 files changed +31
-21
lines changed Original file line number Diff line number Diff line change 1
1
package appscreen ;
2
2
3
- import testerEntities .Chat ;
4
3
5
4
import javax .swing .*;
6
5
import java .awt .*;
Original file line number Diff line number Diff line change 1
1
package appscreen ;
2
2
3
- import testerEntities .*;
4
-
5
3
public interface AppScreenController {
6
4
Chat getChat (String chatID );
7
5
Original file line number Diff line number Diff line change 1
1
package appscreen ;
2
2
3
- import testerEntities .*;
4
3
import java .util .ArrayList ;
5
4
6
5
public class AppScreenLoader implements AppScreenPresenter {
@@ -12,11 +11,10 @@ public class AppScreenLoader implements AppScreenPresenter {
12
11
/**
13
12
* Create the app screen loader (and store its user and chat information)
14
13
* @param username The username of the current user
15
- * @param userDataBase User information
16
14
*/
17
- public AppScreenLoader (String username , UserDataBase userDataBase ){
15
+ public AppScreenLoader (String username , ArrayList < Chat > chats ){
18
16
this .username = username ;
19
- this .chats = userDataBase . getUserChats ( username ) ;
17
+ this .chats = chats ;
20
18
try {
21
19
openScreen ();
22
20
} catch (Exception e ) {
@@ -33,17 +31,4 @@ public void openScreen() {
33
31
this .appScreen = new AppScreen (this .username , this .chats );
34
32
}
35
33
36
- /**
37
- * @return The username of the current user
38
- */
39
- public String getUsername (){
40
- return this .username ;
41
- }
42
-
43
- /**
44
- * @return A list of chats that the user is in
45
- */
46
- public ArrayList <Chat > getChats (){
47
- return new ArrayList <>(this .chats );
48
- }
49
34
}
Original file line number Diff line number Diff line change 1
1
package appscreen ;
2
2
3
- import testerEntities .*;
4
3
5
4
public interface ChatName {
6
5
String getChatName (Chat chat );
Original file line number Diff line number Diff line change
1
+ package appscreen ;
2
+
3
+ import java .util .ArrayList ;
4
+
5
+ public class UserAppScreenGateway {
6
+
7
+ private final UserDataBase userDataBase ;
8
+ private String username ;
9
+ private ArrayList <Chat > userChats ;
10
+
11
+ /**
12
+ * Create gateway between user and appscreen
13
+ * @param userDataBase The user database
14
+ */
15
+ public UserAppScreenGateway (UserDataBase userDataBase ){
16
+ this .userDataBase = userDataBase ;
17
+ }
18
+
19
+ /**
20
+ * Log the user into the system
21
+ * @param user The current user
22
+ */
23
+ public void login (User user ){
24
+ this .username = user .getUsername ();
25
+ this .userChats = userDataBase .getUserChats (this .username );
26
+ AppScreenLoader appScreenLoader = new AppScreenLoader (this .username , this .userChats );
27
+ }
28
+
29
+ }
You can’t perform that action at this time.
0 commit comments