Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago