/**
    Die Klasse BankAccount fuehrt einen einfachen
    Begriff von Bankkonto ein, bei dem ein Konto durch
    seinen Kontostand charakterisiert ist. Ausserdem
    werden einfache Methoden zum Einzahlen und Abheben
    von einem Konto definiert. Die Methoden deposit und
    withdraw sind allgemeiner als in der Spezifikation
    und ueberweisen auch negative Betraege.

    @author  info2
    @version 1.0
*/
public class BankAccount
{   private double balance;
    /**
        Der Standard-Konstruktor setzt den Anfangskontostand auf 0.0.
    */
    public BankAccount()
    {   balance = 0.0;
    }
    /**
        Der Konstruktor setzt den Anfangskontostand fest.
    */
    public BankAccount(double initialBalance)
    {   balance = initialBalance;
    }
    /**
        Die Methode getBalance gibt den aktuellen Kontostand an.
    */
    public double getBalance()
    {   return balance;
    }
    /**
        Die Methode deposit fuegt den Betrag amount zum Kontostand hinzu.
        @param  amount  eingezahlter Betrag, >=0
    */
    public void deposit(double amount)
    {   balance = balance + amount;
    }
    /**
        Die Methode withdraw hebt den Betrag amount vom Konto ab.
        @param  amount  abgehobener Betrag, >=0
    */
    public void withdraw(double amount)
    {   balance = balance - amount;
    }
    /**
        Die Methode transferTo ueberweist den Betrag amount
        von dem aktuellen Konto auf das Konto other.
        @param  other   Bankkonto, auf das amount ueberwiesen wird.
        @param  amount  zu ueberweisender Betrag.
    */
    public void transferTo(BankAccount other, double amount)
    {   withdraw(amount);
        other.deposit(amount);
    }
    /**
        Die Methode toString definiert eine textuelle Repraesentation
        fuer BankAccount-Objekte.
    */
    public String toString()
    {   return "BankAccount[balance = " + balance + "]";
    }
}
