Skip to content

Commit 23275bb

Browse files
committed
Made some improvements to clean design and testing
1 parent 121069e commit 23275bb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package interface_adapters.profile_modification_IA;
2+
import data_access.UserDatabase;
3+
import entities.user_entities.User;
4+
5+
/**
6+
* profile_modification_IA.ChangeController makes ChangeControllerClass implement reportChange to invert the dependency
7+
*/
8+
public class ChangeControllerClass implements ChangeController{
9+
@Override
10+
public boolean reportChange(String username, String password, String feature, String newFeature) {
11+
UserDatabase db = new UserDatabase();
12+
if (db.UserExists(username)){
13+
User user = db.getUser(username);
14+
if (user.PasswordMatch(password) & user.getUsername().equals(username)){
15+
user.changeFeature(feature, newFeature);
16+
// this serializes the change
17+
db.modifyUser(username, user);
18+
return true;
19+
}
20+
}
21+
return false;
22+
}
23+
}

0 commit comments

Comments
 (0)