package com.Test;
class PasswordException extends Exception{
public String toString(){
return("PasswordException:密码错误");
}
}class OverTopException extends Exception{
public String toString(){
return("OverTopException:取款超过限额");
}
}
class BlanceLackException extends Exception{
public String toString(){
return("BlanceLackException:余额不足");
}
}public class Bank { /**
 * @param args
 */
private int top;
private int balance;
private static boolean exceptionSign;
public Bank(int top,int balance){
this.top = top;
this.balance = balance;
this.exceptionSign = false;

}
public void fetchMoney(String password,int money)throws
OverTopExeption,PasswordException,BalanceLackException{
if(password.length()==0)throw new PasswordException();
if(money>top)throw new OverTopException();
    if(money>balance)throw new BalanceLackException();
    

}
public static void main(String[] args) {
// TODO Auto-generated method stub
Bank bank = new Bank(2000,1000);
try{
bank.fetchMoney("1", 500);
bank.fetchMoney(" ",1000);
}catch(PasswordException e){
exceptionSign = true;
System.out.println(e);
}catch(OverTopException e){
exceptionSign = true;
System.out.println(e);
}catch(BalanceLackException e){
exceptionSign = true;
System.out.println(e);
}finally{
if(exceptionSign)System.out.println("有错误产生");
else System.out.println("操作完成");
}
}}
这是一个模拟银行取款业务 的程序 ,不知道哪里错了,求大神指点

解决方案 »

  1.   

    只回答没人回答的。
    ----------------------------------------------------------
    都是拼写错误,你好好检查下fetchMoney和main方法里,那些Exception是否有拼写错误。
    package com.Test;
    class PasswordException extends Exception{
    public String toString(){
    return("PasswordException:密码错误");
    }
    }class OverTopException extends Exception{
    public String toString(){
    return("OverTopException:取款超过限额");
    }
    }
    class BlanceLackException extends Exception{
    public String toString(){
    return("BlanceLackException:余额不足");
    }
    }public class Bank {/**
    * @param args
    */
    private int top;
    private int balance;
    private static boolean exceptionSign;
    public Bank(int top,int balance){
    this.top = top;
    this.balance = balance;
    this.exceptionSign = false;}
    public void fetchMoney(String password,int money)throws
    OverTopExeption,PasswordException,BalanceLackException{
    if(password.length()==0)throw new PasswordException();
    if(money>top)throw new OverTopException();
    if(money>balance)throw new BalanceLackException();
     }
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Bank bank = new Bank(2000,1000);
    try{
    bank.fetchMoney("1", 500);
    bank.fetchMoney(" ",1000);
    }catch(PasswordException e){
    exceptionSign = true;
    System.out.println(e);
    }catch(OverTopException e){
    exceptionSign = true;
    System.out.println(e);
    }catch(BalanceLackException e){
    exceptionSign = true;
    System.out.println(e);
    }finally{
    if(exceptionSign)System.out.println("有错误产生");
    else System.out.println("操作完成");
    }
    }}
      

  2.   

    where is the problem?????