用java模仿ATM(记录的功能似乎有点问题,哪位老大帮我看看)

最近在用java学习OOP,写了一个模仿ATM的程序。

package atm;
import java.io.*;


/**
 * 记录类:记录用户操作,包含存款,取款,转账的相关信息*/
class Record
{
	private String cardNum;
	private String operType;
	private int opAmount;
	
	/*构造方法*/
	Record()
	{
		this.cardNum = null;
		this.operType = null;
		this.opAmount = 0;
	}
	void set_cardNum(String carNum)
	{
		this.cardNum = carNum;
	}
	void set_opType(String type)
	{
		this.operType = type;
		
	}
	void set_opAmount(int amount)
	{
		this.opAmount = amount;
	}
	String get_cardNum()
	{
		return cardNum;
	}
	String get_opType()
	{
		return operType;
	}
	int get_opAmount()
	{
		return opAmount;
	}
	void record_all(String num, String ty, int amo)
	{
		set_cardNum(num);
		set_opType(ty);
		set_opAmount(amo);
	}
}


class Account
{
	private String name;
	private String Number;
	private String Password; 
	private double Remain;
	Record[] record = new Record[10];/*每个账户拥有10个记录单元*/
	public Account()
	{
		for(int i=0;i 9999)||(amount < 0))
		{
			System.out.println("输入不合法,请重新输入:");
			return;
		}
		/*存款操作*/
		if(type == 1)
		{
			Remain+=amount;
			/*操作记录
			 *记录操作账号,金额,类型*/
			record[UserHelper.presentRecord].set_cardNum(UserHelper.get_num());
			record[UserHelper.presentRecord].set_opAmount((int)amount);
			record[UserHelper.presentRecord].set_opType("存款");
			UserHelper.presentRecord++;
		}
		/*取款操作*/
		else if(type == 2)
		{
			if(Remain < amount)/*检查余额是否充足*/
			{
				System.out.println("余额不足");
				return;
			}
			else 
			{
				Remain-=amount;
				record[UserHelper.presentRecord].set_cardNum(UserHelper.get_num());
				record[UserHelper.presentRecord].set_opAmount((int)amount);
				record[UserHelper.presentRecord].set_opType("取款");
				UserHelper.presentRecord++;
			}
		}
	}
}

/*保持当前登录的用户的信息*/
 class UserHelper
{
	/*当前登录账户的卡号和密码*/ 
	private static String Tem_num;
	private static String Temp_psw;
	
	/*当前账户在账户数组的下标*/
	private static int the;
	/*当前记录单元的下标*/
	public static int presentRecord = 0;
	 
	
	static void set_num(String num)
	{
		Tem_num = num;
	}
	static void set_psw(String psw)
	{
		Temp_psw = psw;
	}
	static void set_the(int th)
	{
		the = th;
	}

	static String get_num()
	{
		return Tem_num;
	}
	static String get_psw()
	{
		return Temp_psw;
	}
	static int get_the()
	{
		return the;
	}
}



 class ATM
{
	 Account ac[] = new Account[5];
	 /*构造方法*/
	 public ATM()
	 {
		 for(int i=0;i 999999)||(length_lim <100000))
			{
				System.out.println("密码长度为6位,请重新输入:");
				continue;
			}
			System.out.println("请再次输入新密码:");
			 psw_input2 = reader.readLine();
			
			/*检查两次密码输入是否一致*/
			if(!(psw_input1.equals(psw_input2)))
			{
				System.out.println("两次密码不一致!请重新输入:");
				continue;
			}
			ret = true;
		}while(!ret);
		/*设置新密码*/
		ac[UserHelper.get_the()].setPsw(psw_input1);
		return true;
	}
	
	
	
	/*转账方法:输入要转账的卡号和金额进行转账
	 *首先根据输入的目标卡号找到目标账户,然后从
	 *当前账户扣除要转账的金额*/
	boolean Transform_money() throws IOException 
	{
		System.out.println("请输入您要转账的卡号");
		String dest_num = reader.readLine();
		System.out.println("请输入您要转账的金额:");
		int Transform_num = Integer.parseInt(reader.readLine());
		/*根据用户输入的卡号进行查找*/
		for(int j=0;j


你可能感兴趣的:(Java,java,string,input,class,user,oop)