need help with simple project

im very new to java and i need some help with my code.. theres a particular part in this code to where it gives me an error:

public static boolean readPassword(String PASSWORD_ONE, String PASSWORD_TWO, int MAX_ATTEMPTS)
{
String USER_PASSWORD = TextInputOutput.simpleDialogBox("Enter password: ");
int CURRENT_ATTEMPT;
for (CURRENT_ATTEMPT = 0; CURRENT_ATTEMPT <= MAX_ATTEMPTS; CURRENT_ATTEMPT++)
{
if (USER_PASSWORD.equals(PASSWORD_ONE) || USER_PASSWORD.equals(PASSWORD_TWO))
return true;
else
return false;
}
}

i am using Eclipse, and it says that "This method must return a type boolean." this code, i thought, does return a type boolean. this is a basic password check and this particular method is called upon by another driver class, but we dont need to go there. what is wrong with that part of the code? thanks!

Comments

  • : im very new to java and i need some help with my code.. theres a particular part in this code to where it gives me an error:
    :
    : public static boolean readPassword(String PASSWORD_ONE, String PASSWORD_TWO, int MAX_ATTEMPTS)
    : {
    : String USER_PASSWORD = TextInputOutput.simpleDialogBox("Enter password: ");
    : int CURRENT_ATTEMPT;
    : for (CURRENT_ATTEMPT = 0; CURRENT_ATTEMPT <= MAX_ATTEMPTS; CURRENT_ATTEMPT++)
    : {
    : if (USER_PASSWORD.equals(PASSWORD_ONE) || USER_PASSWORD.equals(PASSWORD_TWO))
    : return true;
    : else
    : return false;
    : }
    : }
    :
    : i am using Eclipse, and it says that "This method must return a type boolean." this code, i thought, does return a type boolean. this is a basic password check and this particular method is called upon by another driver class, but we dont need to go there. what is wrong with that part of the code? thanks!
    :
    It does [b]not always[/b] return a boolean. If MAX_ATTEMPTS < 0 then tdoes the function return nothing.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion