登录功能的基本实现

package demo01;

import java.util.Scanner;

public class demo08 {

public static void main(String[] args){
String username = "root";
String password = "admin";
for(int x=0;x<3;x++){
Scanner sc = new Scanner(System.in);
System.out.println("请输入用户名:");
String name = sc.nextLine();
System.out.println("请输入密码");
String psd = sc.nextLine();

if(name.equals(username)&& psd.equals(password)){
System.out.println("登陆成功,进入游戏环节");
demo09.Start();
break;
}else if(2-x==0){
System.out.println("您的账号已被冻结,请联系管理员");
}else{
System.out.println("登录失败,您还有"+(2-x)+"次机会");
}
}
}

}

猜你喜欢

转载自www.cnblogs.com/WTBK/p/9393203.html