模拟银行自动取款机项目代码参考
模拟银行自动取款机项目代码参考
使用语言:java
设计Account 类
设计ATMException异常 类
设计ATM类
Account 类
private String name;
private String id;
private String password;
private double balance;
Accout()
{
init();
private void init(){
this.name="无名氏";
this.id="";
this.password="888888";
this .balace=0.0;
for(int i=0;i<6;i++){
it temp=(int)(Math.random()*100 %10;
id+=temp;
}
@Override
public void showinfo()
return "户主:"+this.getName()+"\n帐号:"+this.getid()+\n余:"+this.balance();
{
private static final Scanner in=new Scanner(System.in);
private static int choice;
pricate static Account account;
public Static void showMeu()
{
System.out.println("欢迎使用Atm系统");
System.out.println("\t1.开户");
System.out.println("\t2.查询");
System.out.println("\t3.存款");
System.out.println("\t4.取款");
System.out.println("\t5.修改密码");
System.out.println("\t6.退出");
System.out.println("请选择:");
choice=in.nextint();
public static void initAccount()
{
account=new Account();
System.out.println("开户成功,以下是你账户的信息");
}
public static boolean draw(int number)
{
try{
if(number<=0)
{
throw new ATMExcaption("取款金额非法!");
}
else if(number>account.getBalance())
{
throw new ATMExcaption ("取款金额大于余额");
}
else
{
account.setBalance(account.getBalance()-number);
System.out.println("取款成功!");
return true;
{
下一篇 >>