Skip to content

Commit 277a2e0

Browse files
committed
Made the change serialized
1 parent 4aa4ead commit 277a2e0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/UserModificationUI.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void actionPerformed(ActionEvent e) {
4444
String username = (usernameField.getText());
4545
String password = (passwordField.getText());
4646
String item = cb.getSelectedItem().toString();
47-
String newFeature = (passwordField.getText());
47+
String newFeature = (newFeatureField.getText());
4848
boolean success = reportChange(username, password, item, newFeature);
4949
if (success){
5050
label.setText("Your " + item + " was successfully changed.");
@@ -73,13 +73,15 @@ public void actionPerformed(ActionEvent e) {
7373
// ChangeController makes UI implement reportChange to invert the use-case --> UI dependency
7474
@Override
7575
public boolean reportChange(String username, String password, String feature, String newFeature) {
76-
UserDatabase db = UserDatabase(accounts);
76+
UserDatabase db = new UserDatabase();
7777
if (db.UserExists(username)){
7878
User user = db.getUser(username);
79-
if (user.PasswordMatch(password) && user.getUsername().equals(username)){
79+
if (user.PasswordMatch(password) & user.getUsername().equals(username)){
8080
user.changeFeature(feature, newFeature);
81+
// this serializes the change
82+
db.modifyUser(username, user);
8183
return true;
82-
}
84+
}
8385
}
8486
return false;
8587
}

0 commit comments

Comments
 (0)