add files
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
|
||||
class User {
|
||||
private String username;
|
||||
private String encryptedPassword;
|
||||
private int score;
|
||||
private boolean hint = false;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String username, String encryptedPassword, int score) {
|
||||
setUsername(username);
|
||||
setEncryptedPassword(encryptedPassword);
|
||||
setScore(score);
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
||||
return (username);
|
||||
|
||||
}
|
||||
|
||||
public void setEncryptedPassword(String encryptedPassword) {
|
||||
this.encryptedPassword = encryptedPassword;
|
||||
|
||||
}
|
||||
|
||||
public String getEncryptedPassword() {
|
||||
|
||||
return (encryptedPassword);
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
|
||||
return (score);
|
||||
}
|
||||
|
||||
public void changePassword(String oldPass, String newPass) {
|
||||
|
||||
if (!oldPass.equals(encryptedPassword)) {
|
||||
System.out.println("Old Password Not Valid!! ");
|
||||
return;
|
||||
} else {
|
||||
String check = AuthService.getObject().check(newPass);
|
||||
System.out.println(check);
|
||||
if (!check.equals("Password Not Valid!")) {
|
||||
encryptedPassword = newPass;
|
||||
System.out.println("Password changed successfully.");
|
||||
return;
|
||||
|
||||
} else {
|
||||
System.out.println("New Password Not Valid!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addScore(int wordLength) {
|
||||
score += wordLength;
|
||||
|
||||
}
|
||||
|
||||
public boolean useHint() {
|
||||
if (hint) {
|
||||
System.out.println(" you used your hint!");
|
||||
return (false);
|
||||
} else if (score <= 0) {
|
||||
System.out.println("you dont have enough score ");
|
||||
return (false);
|
||||
} else {
|
||||
|
||||
hint = true;
|
||||
return (true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user