📄 creditaccount.java
字号:
public class CreditAccount extends Account {
private int CanCeiling;
private double ceiling;
private double ceilingMax;
/**
* ceilingMax of get
*
* @return ceilingMax
*/
public double getCeilingMax() {
return ceilingMax;
}
/**
* ceilingMax of set
*
* @param ceilingMax set {bare_field_name}
*/
public void setCeilingMax(double ceilingMax) {
this.ceilingMax = ceilingMax;
ceiling=ceilingMax;
}
public CreditAccount(long id, String password, String name, String personId, String email) {
this.setId(id);
this.setPassword(password);
this.setName(name);
this.setPersonId(personId);
this.setEmail(email);
this.setBalance(0);
ceiling=0;
CanCeiling = 1;
System.out.println("创建成功");
}
public void withdraw(double sum) {
double balance = this.getBalance();
balance -= sum;
if (balance < 0) {
if (ceiling + balance < 0) {
balance += sum;
System.out.println("已经超支,无法支付,系统退出");
System.exit(0);
}
else{
this.setBalance(balance);
ceiling=ceiling+balance;
System.out.println("支付成功,透资余额为"+ceiling);
}
}
else {
this.setBalance(balance);
System.out.println("支付成功,当前余额为"+balance);
}
}
public void deposit(double sum){
double balance=this.getBalance();
if(balance<0){
ceiling+=sum;
if(ceiling>ceilingMax) ceiling=ceilingMax;
}
balance+=sum;
this.setBalance(balance);
System.out.println("存款成功,当前余额为"+balance);
}
/**
* ceiling of get
*
* @return ceiling
*/
public double getCeiling() {
return ceiling;
}
/**
* ceiling of set
*
* @param ceiling
* set {bare_field_name}
*/
public void setCeiling(double ceiling) {
this.ceiling = ceiling;
}
/**
* canCeiling of get
*
* @return canCeiling
*/
public int getCanCeiling() {
return CanCeiling;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -