我正在尝试制作一个登录系统,当我登录时,会出现一个小程序。由于某种原因,它不断出现错误。这是我所拥有的:
import java.util.Scanner;
class login {
private static Scanner luci;
public static void main(String args[]){
luci = new Scanner(System.in);
String idInput;
System.out.println("Please type ID: ");
idInput = luci.nextLine();
String passwordInput;
System.out.print("Please type Password: ");
passwordInput = luci.nextLine();
if(passwordInput.equals("Atlas") && (idInput.equals("Seymore"))){
System.out.println("Authentification complete!");
}if(passwordInput.equals("Admin") && (idInput.equals("Admin"))){
System.out.println("Authentication complete: Reverting To Program.");
try {
Thread.sleep(800);
} catch(InterruptedException e) {
}
loginaccepted objectName = new loginaccepted();
objectName.paint(null);
}else{
System.out.println("Rong ID or Password!");
}
}
}
这里是 loginaccepted.class:
import java.applet.*;
import java.awt.Graphics;
public class loginaccepted extends Applet{
public void paint(Graphics g){
g.drawLine(10, 20, 50, 60 );
}
}
任何帮助表示赞赏。我这样做只是为了好玩,并帮助提高我对 Java 编程语言的了解。