标签:
public class Bank { Double qian=0.0; double newBank(double a) { qian=qian+a; return qian; } double withDrawal(double dAmount) throws Exception { if(dAmount>qian) { throw new Exception("InsufficientFundsException"); } if(dAmount<0) { throw new Exception("NagativeFundsException"); } qian=qian-dAmount; return qian; } public static void main(String[] args) throws Exception { Bank a=new Bank(); a.newBank(100); a.withDrawal(-50); } }
public static void main(String[] args) throws Exception { Bank a=new Bank(); a.newBank(100); a.withDrawal(150); }
标签:
原文地址:http://www.cnblogs.com/wenwen123/p/5537687.html