@@ -44,7 +44,7 @@ public void actionPerformed(ActionEvent e) {
44
44
String username = (usernameField .getText ());
45
45
String password = (passwordField .getText ());
46
46
String item = cb .getSelectedItem ().toString ();
47
- String newFeature = (passwordField .getText ());
47
+ String newFeature = (newFeatureField .getText ());
48
48
boolean success = reportChange (username , password , item , newFeature );
49
49
if (success ){
50
50
label .setText ("Your " + item + " was successfully changed." );
@@ -73,13 +73,15 @@ public void actionPerformed(ActionEvent e) {
73
73
// ChangeController makes UI implement reportChange to invert the use-case --> UI dependency
74
74
@ Override
75
75
public boolean reportChange (String username , String password , String feature , String newFeature ) {
76
- UserDatabase db = UserDatabase (accounts );
76
+ UserDatabase db = new UserDatabase ();
77
77
if (db .UserExists (username )){
78
78
User user = db .getUser (username );
79
- if (user .PasswordMatch (password ) && user .getUsername ().equals (username )){
79
+ if (user .PasswordMatch (password ) & user .getUsername ().equals (username )){
80
80
user .changeFeature (feature , newFeature );
81
+ // this serializes the change
82
+ db .modifyUser (username , user );
81
83
return true ;
82
- }
84
+ }
83
85
}
84
86
return false ;
85
87
}
0 commit comments