【自动化__持续集成】___java___模拟登陆
一、代码如下
public void login() { String acatualUsername= "woniuxy"; String acatualPassword= "123456"; //Scanner sc= new Scanner(System.in); //System.out.println("请输入用户名:"); //String name= sc.nextLine(); //System.out.println("请输入用密码:"); //String password= sc.nextLine(); while(true) { Scanner sc= new Scanner(System.in); System.out.println("请输入用户名:"); String name= sc.nextLine(); if(!name.equals(acatualUsername)) { System.out.println("用户名输入错误!"); }else { while(true) { System.out.println("请输入用密码:"); String password= sc.nextLine(); if(!password.equals(acatualPassword)) { System.out.println("密码输入错误"); }else{ System.out.println("恭喜,登录成功"); break; } } } } }