I am trying to set my true and false return from my method in another class as the conditional to my if statement. We are creating a password generator. Are set password is changit. If the user enters changeit as the original password then the new password the user would like to enter will become the password. if not then the users password will stay the same as the original password. I created a method that returned a true or false if the oldPassword is equal to password. else it will return false. I need this return to go back in my main file and to be used in an if statement. Please help me! i am posting my if statements (which are in a separate file called Main.java) and my boolean method (which are in a separate file called Password.java) all my code works except for my if statements
//My method in anotherfile called Password.java
public boolean checkPassword(String oldPassword)
{
if (password.equals(oldPassword))
{
System.out.println("True");
return true;
}
else {
System.out.println("False");
return false;
}
}
//my constructor
passwordObject.checkPassword(oldPassword);
//my if statement for main.java to show if i was able to successfully change my password.
if (checkPassword == true)
{
System.out.println("Your password change was successful");
}
else
{
System.out.println("Your password change was unsucessesful");
}
Aucun commentaire:
Enregistrer un commentaire