/** Die Klasse CheckingAccount fuehrt einen einfachen Begriff von Girokonto ein. CheckingAccount erweitert BankAccount um Kosten fuer jede Transaktion. @author info2 @version 1.0 */ public class CheckingAccount extends BankAccount { /** Anzahl der freien Transaktionen = 2 */ private static final int FREE_TRANSACTIONS = 2; /** Gebuehr pro Transaktion = 0.5 */ private static final double TRANSACTION_FEE = 0.5; private int transactionCount; /** Der Standard-Konstruktor setzt die Zahl der Transaktionen auf 0. */ public CheckingAccount() { super(); // unnoetig, da von Java automatisch aufgerufen transactionCount = 0; } /** Der Konstruktor setzt den Anfangskontostand fest und die Zahl der Transaktionen auf 0. */ public CheckingAccount(double initialBalance) { super(initialBalance); // muss die erste Anweisung sein! transactionCount = 0; } /** Die Methode deductFees zieht die angefallenen Gebuehren vom Kontostand ab. Dabei wird die Anzahl der freien Transaktionen beruecksichtigt. */ public void deductFees() { if (transactionCount > FREE_TRANSACTIONS) { double fees = TRANSACTION_FEE * (transactionCount-FREE_TRANSACTIONS); super.withdraw(fees); } transactionCount = 0; } /** Die Methode deposit fuegt den Betrag amount zum Kontostand hinzu und erhoeht die Anzahl der Transaktionen um 1. @param amount eingezahlter Betrag, >=0 */ public void deposit(double amount) { transactionCount++; super.deposit(amount); } /** Die Methode withdraw hebt den Betrag amount vom Konto ab und erhoeht die Anzahl der Transaktionen um 1. @param amount abgehobener Betrag, >=0 */ public void withdraw(double amount) { transactionCount++; super.withdraw(amount); } /** Die Methode transferTo wird von BankAccount geerbt. Die Erh�hung von transactionCount geschieht ueber die dynamische Bindung von withdraw im Rumpf von BankAccount.transferTo public void transferTo(BankAccount other, double amount) { super.trasnferTo(other,amount); } */ /** Die Methode toString definiert eine textuelle Repraesentation fuer CheckingAccount-Objekte. */ public String toString() { return "CheckingAccount[balance = " + getBalance() + ", transactionCount = " + transactionCount + "]"; } }