写个程序,有个bug找不到,求助

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Register {
static Scanner s = new Scanner(System.in);
static String [] Account=new String [5];
static String [] Password=new String [5];
static String [] Mailbox=new String [5];
static String [] Telephone=new String [5];
String   account;
String password;
String mailbox;
String telephone;
int A ;
int P;
int M;
int T;
int R;
boolean k;
//整合输入的信息
public void register(){
if (R==5){
System.out.println("注册的账号已达到服务器的限额,不能再注册了!");
return;
}
zhangHao();
miMa();
youXiang();
shouJi();
R++;
}
//输入注册账号
public void zhangHao(){
System.out.println("请输入注册账号:");
//判断输入的账号是否在服务器的后台已经存在;
boolean b=true;
while(b){
account=s.nextLine();
for(int i=0;i
if(account.equals(Account[i])){
System.out.println("该账号已有");
System.out.println("请重新输入注册账号:");
break;
}else{
b=false;
}
}
}
k=Register.definition("^[A-Z]{1}[0-9a-zA-Z\\.@]{3,19}$",account);
while(k!=true){
System.out.println("输入的注册账号有误,请重新输入:");
account=s.nextLine();
k=Register.definition("^[A-Z]{1}[0-9a-zA-Z\\.@]{3,19}$",account);
}
Account[A]=account;
A++;
}
//输入注册密码
public void miMa(){
System.out.println("请输入注册密码:");
password=s.nextLine();
k=Register.definition("[\\w\\.@]{6,20}",password);
while(k!=true){
System.out.println("输入的注册密码有误,请重新输入:");
password=s.nextLine();
k=Register.definition("[\\w\\.@]{6,20}",password);
}
Password[P]=password;
P++;
}
//输入注册的邮箱
public void youXiang(){
System.out.println("请输入注册的邮箱:");
mailbox=s.nextLine();
k=Register.definition("[\\w]{6,12}@[a-zA-Z0-9]{2,10}\\.[a-zA-Z0-9]{2,3}",mailbox);
while(k!=true){
System.out.println("输入的注册的邮箱有误,请重新输入:");
mailbox=s.nextLine();
k=Register.definition("[\\w]{6,12}@[a-zA-Z0-9]{2,10}\\.[a-zA-Z0-9]{2,3}",mailbox);
}
Mailbox[M]=mailbox;
M++;
}
//输入联系方式
public void shouJi(){
System.out.println("请输入联系方式:");
telephone=s.nextLine();
k=Register.definition("^[1][358][0-9]{9}$",telephone);
while(k!=true){
System.out.println("输入的联系方式,请重新输入:");
telephone=s.nextLine();
k=Register.definition("^[1][358][0-9]{9}$",telephone);
}
Telephone[T]=telephone;
T++;
}
//正则表达式语法
public static boolean definition(String regex,String res){
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(res);
boolean b = m.matches();
return b;
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;

public class Signin {
static Scanner s = new Scanner(System.in);
String account;
String password;
public Signin() {
}

public void get() {
System.out.println("请输入登录账号:");
account = s.nextLine();
System.out.println("请输入密码:");
password = s.nextLine();
boolean b =true;
while(b){
//判断输入的账号是否正确
for(int i=0;i
String   r1 = Register.Account[i];
if(r1.equals(account)){
//如果账号正确,去匹配密码
//判断输入密码与账号是否匹配
String r2= Register.Password[i];
if(r2.equals(password)){
System.out.println(Register.Mailbox[i]);
System.out.println(Register.Telephone[i]);
b=false;
return;
}
}
}
System.out.println("账号不存在或密码错误,请重新输入:");
System.out.println("请输入登录账号:");
account = s.nextLine();
System.out.println("请输入密码:");
password = s.nextLine();
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;

public class Test {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
Register register=new Register();
Signin signin =new Signin();
System.out.println("Welcome to user information management system!");
boolean isOver = false;
while (!isOver)
{
isOver = homePage(register,signin);
}
}
//主页菜单选项
private static boolean homePage(Register register,Signin signin) {
System.out.println("1 Registration");
System.out.println("2 Login");
System.out.println("3 Exit");
int index = s.nextInt();
switch(index){
case 1:
register.register();
break;
case 2:
signin.get();
break;
case 3:
return true;
default:
break;
}
return false;
}

}
-------------------------------------------------------------------------------------------------------------------
错误提示:
Exception in thread "main" java.lang.NullPointerException
at yonghu.Signin.get(Signin.
at yonghu.Test.homePage(Test.
at yonghu.Test.main(Test.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值