Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I am making a login form and it works right now but I was told I need to make it into 2 classes a

So I am making a login form and it works right now but I was told I need to make it into 2 classes a tester class and then the login form. In the tester class I need the scanner and I need to put the name and password. Also when I type the right name and password in it just states true and I cant find out how to change it into a sentence that says like login succusessful. I Also need to have a reset button and i dont know how to implement that only using the cousnil becauase we are not allowed to use a j frame.

What I need

- Make it into 2 classes a tester and a loginform

- put the scanner in the tester class

- put the name and password in the tester class

- Dont use a j frame

- i need a reset button

import java.util.Scanner;

public class LoginForm {

private String userName;

private String password;

private String button;

private String inputString;

private boolean inputState;

public LoginForm() {

this.userName = "admin";

this.password = "password";

this.inputState = true;

this.inputString = "";

}

public void input(String text) {

if (inputState) {

inputString += text;

inputState = false;

} else {

inputString += text;

inputState = true;

}

}

public void click(String button) {

this.button = button;

if (button.equals("Submit")) {

System.out.println(loggedIn());

} else {

userName = "";

password = "";

inputState = true; // if the user never provides password, inputState will remain false.

}

}

public boolean loggedIn() {

if (inputString.equals(userName + password)) {

return true;

} else {

userName = "";

password = "";

inputState = true;

return false;

}

}

public static void main(String[] args) {

LoginForm test = new LoginForm();

Scanner getInput = new Scanner(System.in);

System.out.println("Enter the username: ");

String username=getInput.next();

System.out.println("Enter the password: ");

String password=getInput.next();

test.input(username);

test.input(password);

test.click("Submit");

}

}

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

More Books

Students also viewed these Databases questions