using System; /// \mainpage Doxygen Demo. /// \section intro_sec Introduction /// This documentation serves as a Doxygen demonstration. /// We document the BankAccount class and a number of /// specialized bank account classes. /// /// A simple bank account created as an everyday example /// for the OOP course. Used in particular for demonstrating inheritance. /// /// /// /// BankAccount ba = new BankAccount("Peter"); /// ba.Deposit(100.0); /// ba.Withdraw(50.0); /// /// public class BankAccount { protected double interestRate; protected string owner; protected decimal balance; /// /// Construct a bank account from owner, balance, and interestRate. /// /// The owners name /// The initial amount of this account /// /// The interest rate. /// Annual interet is calculated as balance * interestRate /// public BankAccount(string o, decimal b, double ir) { this.interestRate = ir; this.owner = o; this.balance = b; } /// /// Construct a bank account from owner and interestRate. /// /// The owners name /// /// The interest rate. /// Annual interet is calculated as balance * interestRate /// public BankAccount(string o, double ir): this(o, 0.0M, ir) { } /// /// Returns the current amount of the bank account /// with affecting the account. /// /// The amount of money public virtual decimal Balance { get {return balance;} } /// /// /// Withdraw an amount of money from the account. /// This decreases the balance of the account. /// /// /// /// The amount of money to withdraw from the account. /// Precondition: Must be non-negative. /// public virtual void Withdraw (decimal amount) { balance -= amount; } /// /// Withdraw an amount of money from the account. /// This increases the balance of the account. /// /// /// The amount of money to deposit to the account. /// Precondition: Must be non-negative. /// public virtual void Deposit (decimal amount) { balance += amount; } /// /// Add the annual interest to the account. /// This may increase the current balance of the account. /// public virtual void AddInterests() { balance += balance * (Decimal)interestRate; } /// /// Return a text string that represents this account /// for output purposes /// public override string ToString() { return owner + "'s account holds " + + balance + " kroner"; } }