package cn.edu.bjut.chapter4; public class CreditCard extends Card { private double overdraftLimit; // 透支额度 public CreditCard(String accountNumber, double balance, double overdraftLimit) { super(accountNumber, balance); this.overdraftLimit = overdraftLimit; } public CreditCard(String accountNumber, double overage) { this(accountNumber, overage, 0); } public double getOverdraftLimit() { return this.overdraftLimit; } public void setOverdraftLimit(double overdraftLimit) { this.overdraftLimit = (overdraftLimit >= 0 ? overdraftLimit : 0); } @Override public boolean draw(double money) { if (balance + overdraftLimit < money) { return false; } balance -= money; return true; } }