怎么让某个类不能使用某个方法?
创建一个银行账户Account 类,有存款,取款等方法,在创建两个子类,其中有一个是SavingAccount,SavingAccount不能透支,所以能否使SavingAccount不访问取款方法?
代码如下(没写完):
package pkg;
public class test9_3 {
	public void main(String[] args)
	{
//		SavingAcc saving = new SavingAcc();
	}			
	public class Account
	{
		int accountNum= 0;
		private double balance = 0;//yu e
		private double yearInterest = 0;
		private String openDate = null ;		
		Account(int accountNum , double balance , double yearInterest ,String openDate)
		{
			this.accountNum = accountNum;
			this.balance = balance ;
			this.yearInterest = yearInterest ;
			this.openDate = openDate ;
			System.out.print("this is Account class");
		}		
//		Account(){}				
		public double getBanlance()
		{
			return balance;
		}				
		public void  deposit(double depositMoney)
		{
			balance += depositMoney ;  
		}		
		public void drawMoney(double DMoney)
		{
			balance -=DMoney;
		}
	}
}
package pkg;
import pkg.test9_3.Account;
public class SavingAcc extends Account {
	SavingAcc(test9_3 test9_3, int accountNum, double balance,double yearInterest, String openDate) {
		test9_3.super(accountNum, balance, yearInterest, openDate);
		// TODO Auto-generated constructor stub	
	if(this.getBanlance() < 0)
	{
		System.out.println("your Account's balance is lower than $0");
	}
	else
		;
	}
}
------解决方案--------------------
SavingAccount 的 drawMoney 抛出 UnsupportedOperationException
------解决方案--------------------
------解决方案--------------------