overdraftaccount.java

来自「一些java的小程序.包括排序,一些bank的小计算,」· Java 代码 · 共 53 行

JAVA
53
字号
import java.math.*;public class OverdraftAccount extends BankAccount{	// Add new data here.	private double overdraftLimit;	// Constructor with 2 parameters	public OverdraftAccount(String ownersName, double openingBalance)	{		super(ownersName, openingBalance);	}	// Constructor with 3 parameters	public OverdraftAccount(String ownersName, double openingBalance, double aLimit)	{			      super(ownersName, openingBalance);	      if(openingBalance - aLimit > aLimit)		  	overdraftLimit = aLimit;		  else            aLimit = openingBalance;}	// add any get/set methods here.	public void setLimit(double aLimit)	{		overdraftLimit = aLimit;			}		public double getLimit()	{		return overdraftLimit;	}	// Override methods here.	public void withdraw(double amount)	{		double tempBalance = getBalance();		if(Math.abs((tempBalance -= amount)) <= overdraftLimit)		{			setBalance(tempBalance -= amount);		}			}	public String toString()	{		//super.toString();		return super.toString() +", limit:" + getLimit();	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?