creditaccount.java
来自「通过图形用户界面输入一句话」· Java 代码 · 共 58 行
JAVA
58 行
/**
*
*/
package com.hp.gdcc.training.homework39;
/**
* @author yanshuo
*
*/
public class CreditAccount extends Account {
/**
* 透支额度
*/
private double ceiling;
public CreditAccount() {
// TODO Auto-generated constructor stub
}
/**
* 构造方法
*
* @param id
* @param password
* @param name
* @param personId
* @param email
* @param accountType
*/
public CreditAccount(long id, String password,
String name, String personId, String email, int accountType) {
super(id, password, name, personId, email, accountType);
}
/**
* 取款方法
*
* @param withdrawAmount
* @return boolean(true:取款成功; false:取款失败;)
*/
public boolean withdraw(double withdrawAmount){
double balance = this.getBalance();
double balanceAfterWithdraw = balance - withdrawAmount;
if(balanceAfterWithdraw >= -this.ceiling){
this.setBalance(balanceAfterWithdraw);
return true;
}else{
return false;
}
}
public double getCeiling() {
return ceiling;
}
public void setCeiling(double ceiling) {
this.ceiling = ceiling;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?