Question: /** A class for simulating a login form. */ public class LoginForm { private String username; private String password; private String currentUsername; private String currentPassword;

/**

A class for simulating a login form.

*/

public class LoginForm

{

private String username;

private String password;

private String currentUsername;

private String currentPassword;

private boolean logged;

private boolean firstInput;

/**

Setup a new login form.

*/

public LoginForm(String username, String password)

{

this.username = username;

this.password = password;

reset();

}

// Uses text parameter and sets the current username and current password

public void input(String text)

{

//-----------Start below here. To do: approximate lines of code = 5

// if this is the first input (Hint: use the firstInput variable) , must be the username so set currentUsername = text

// and set firstInput to false. Otherwise, must be the password so set currentPassword

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

private boolean checkLogin()

{

//-----------Start below here. To do: approximate lines of code = 5

// if username not equal to currentUsername, return false

// if password not equal to currentPassword return false

// otherwise return true

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

// Called after user enters username and password

// button parameter is either "Submit" or "Reset"

public void click(String button)

{

//-----------Start below here. To do: approximate lines of code = 7

// if button is "Submit" then

// call checkLogin()

// if checkLogin() returns true, set logged to true

// else call reset()

// else if button equals "Reset"

// call reset()

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

private void reset()

{

currentUsername = "";

currentPassword = "";

logged = false;

firstInput = true;

}

public boolean loggedIn()

{

return logged;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!