Skip to content

Commit e761c06

Browse files
committed
For both my features, I fixed all IntelliJ warnings, added JDoc and made improvements to abstraction.
1 parent 23275bb commit e761c06

File tree

16 files changed

+69
-75
lines changed

16 files changed

+69
-75
lines changed

src/main/java/entities/user_entities/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import data_access.UserDatabase;
44
import entities.chat.Chat;
5+
import interface_adapters.appscreen.UserAppScreenGateway;
56
import interface_adapters.profile_modification_IA.UserAuthenticationI;
67
import interface_adapters.login_interface_adapters.Login;
78
import use_cases.user_attribute_modification_use_case.Changeable;
8-
import interface_adapters.app_screen_interface_adapters.UserAppScreenGateway;
99

1010
import java.io.File;
1111
import java.io.Serializable;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package interface_adapters.User_search_IA;
2-
32
import entities.user_entities.User;
43
import java.util.List;
5-
4+
/**
5+
* allows for the User Database (whatever type it may be) to present all its users in a list format.
6+
*/
67
public interface IRetrieveList {
78
List<User> getList();
89
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package interface_adapters.User_search_IA;
22

3-
// UI implements this interface to invert the dependency of UI on the inner layers
3+
/**
4+
* Implemented interface to invert the dependency of UI on the inner layers
5+
*/
46
public interface UserPresenter {
57
String showProfile(String username);
68
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package interface_adapters.User_search_IA;
2+
import data_access.UserDatabase;
3+
import entities.user_entities.User;
4+
import use_cases.user_profile_display_use_case.UserReader;
5+
6+
/**
7+
* User_search_IA.UserPresenter makes us implement showProfile to invert the dependency
8+
*/
9+
public class UserPresenterClass implements UserPresenter{
10+
@Override
11+
public String showProfile(String username) {
12+
// setting up access to the database of users:
13+
UserDatabase db = new UserDatabase();
14+
if (db.UserExists(username)){
15+
User user = db.getUser(username);
16+
UserReader reader = new UserReader();
17+
String[] features = reader.ProfileReader(user);
18+
String email = features[1];
19+
return("<html>Username: " + username + "<br>Email: " + email + "</html>");
20+
}
21+
else{
22+
return("User with given username does not exist.");
23+
}
24+
}
25+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package interface_adapters.User_search_IA;
2-
32
import use_cases.user_registration_use_cases.UserExists;
43
import entities.user_entities.User;
5-
// gives access to user entity.
4+
5+
/**
6+
* gives access to user entity.
7+
*/
68
public interface UserRetriever extends UserExists {
79
User getUser(String username);
810
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package interface_adapters.profile_modification_IA;
22

33
/**
4-
* To make a change to User entity.
4+
* To make a change to User entity, report if successful.
55
*/
66
public interface ChangeController {
7-
public boolean reportChange(String username, String password, String feature, String newFeature);
7+
boolean reportChange(String username, String password, String feature, String newFeature);
88
}

src/main/java/interface_adapters/profile_modification_IA/UserAuthenticationI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
* allows for ChangeController to authenticate user's username and password.
55
*/
66
public interface UserAuthenticationI {
7-
public Boolean PasswordMatch(String attempt);
7+
Boolean PasswordMatch(String attempt);
88
}

src/main/java/interface_adapters/profile_modification_IA/UserModificationGateway.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import entities.user_entities.User;
44

5-
// allows for the serialized data_access.UserDatabase to update when changes occur to user attributes.
5+
/**
6+
* allows for the serialized data_access.UserDatabase to update when changes occur to user attributes.
7+
*/
68
public interface UserModificationGateway {
7-
public void modifyUser(String oldUsername, User modified);
9+
void modifyUser(String oldUsername, User modified);
810
}
911

src/main/java/screens/Profile_screen/UserSearchUI.java

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
package screens.Profile_screen; /**
2-
* Provides the UI elements
3-
*/
4-
import data_access.UserDatabase;
5-
import entities.user_entities.User;
6-
import interface_adapters.User_search_IA.UserPresenter;
7-
import use_cases.user_profile_display_use_case.UserReader;
8-
1+
package screens.Profile_screen;
2+
import interface_adapters.User_search_IA.UserPresenterClass;
93
import javax.swing.*;
104
import java.awt.*;
115
import java.awt.event.ActionEvent;
126
import java.awt.event.ActionListener;
13-
import java.io.File;
14-
157

16-
public class UserSearchUI implements UserPresenter {
17-
private JLabel label;
8+
/**
9+
* Provides the UI elements
10+
*/
11+
public class UserSearchUI {
12+
private final JLabel label;
13+
private final UserPresenterClass p = new UserPresenterClass();
1814

1915
public UserSearchUI() {
2016
final JFrame frame = new JFrame();
@@ -27,7 +23,7 @@ public UserSearchUI() {
2723
field.addActionListener(new ActionListener() {
2824
@Override
2925
public void actionPerformed(ActionEvent e) {
30-
label.setText(showProfile(field.getText()));
26+
label.setText(p.showProfile(field.getText()));
3127
}
3228

3329
});
@@ -38,31 +34,6 @@ public void actionPerformed(ActionEvent e) {
3834
frame.setVisible(true);
3935
}
4036

41-
/**
42-
* User_search_IA.UserPresenter makes UI implement showProfile to invert the use-case --> UI dependency
43-
*/
44-
@Override
45-
public String showProfile(String username) {
46-
// setting up access to the database of users:
47-
UserDatabase db = new UserDatabase();
48-
if (db.UserExists(username)){
49-
User user = db.getUser(username);
50-
UserReader reader = new UserReader();
51-
String[] features = reader.UserReader(user);
52-
String email = features[1];
53-
return("<html>Username: " + username + "<br>Email: " + email + "</html>");
54-
}
55-
else{
56-
return("User with given username does not exist.");
57-
}
58-
}
59-
60-
// for trying out the code:
61-
// public static void main(String[] args) {
62-
// new Profile_screen.UserSearchUI();
63-
//
64-
// }
65-
6637
}
6738

6839

src/main/java/screens/profile_update_screen/UserModificationUI.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package screens.profile_update_screen;
22
import interface_adapters.profile_modification_IA.ChangeControllerClass;
3-
43
import javax.swing.*;
54
import java.awt.*;
65
import java.awt.event.ActionEvent;
@@ -9,7 +8,7 @@
98

109

1110
/**
12-
* Provides the UI elements
11+
* Provides the UI elements.
1312
*/
1413
public class UserModificationUI {
1514
ChangeControllerClass c = new ChangeControllerClass();

0 commit comments

Comments
 (0)