/**
*
* @author a2643116636
* @date 2020-04-12
*
*/
public class Register {
// 方法
public boolean consumer(String user,String password,String pd) {
boolean com=true;
if(user.length()>=3&&password.length()>=6) { // 用户名长度为3,密码长度为6
if(password.equals(pd)) { // 第一次输入密码与第二次输入密码一致
com=false; // com如果为false则结束
System.out.println("注册成功!请牢记用户名和密码。"); // 满足两个if的3个条件注册成功
}else { // 不满足第一次输入密码与第二次输入密码一致
System.out.println("两次密码不一致!");
}
}else { // 用户名长度不为3,密码长度不为6
com=true; // com如果为true则继续
System.out.println("用户长度不能小于3,密码长度不能小于6!");
}
return com;
}
}
// 测试类
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String user1;
String password1;
String pd1;
boolean a = false; // 假设a为false
// 创建对象
Register s = new Register();
System.out.println("***欢迎进入注册系统***\n");
do {
System.out.println("请输入用户名:");
user1 = input.next();
System.out.println("请输入密码:");
password1 = input.next();
System.out.println("请输入再次密码:");
pd1 = input.next();
if (s.consumer(user1, password1, pd1)) {
} else {
break;
}
} while (a = true);
}
}
java基础,String方法实现会员注册
猜你喜欢
转载自blog.csdn.net/a2643116636/article/details/105474722
今日推荐
周排行