using System;
///
/// A specialization of BankAccount for saving purposes.
///
public class SavingsAccount: BankAccount {
/// A constructor that constructs a Savings account on the
/// basis of an owner and the interestrate. The balanced defaults
/// to 0.0.
/// The owners name
/// The interestrate
public SavingsAccount(string o, double ir):
base(o, 0.0M, ir) {
}
/// A constructor that constructs a SavingsAccount on the
/// basis of an owner, balance, and the interestrate
/// The owners name
/// The initial balance of the account
/// The interestrate
public SavingsAccount(string o, decimal b, double ir):
base(o, b, ir) {
}
/// Withdraw an amount from the savings account
/// The amount withdrawn
/// In case of insufficient funds
/// an exception is thrown
public override void Withdraw (decimal amount) {
if (amount < balance)
balance -= amount;
else
throw new Exception("Cannot withdraw");
}
///
/// Add the annual interest to the savings account.
/// This may increase the current balance of the account.
///
public override void AddInterests() {
balance = balance + balance * (decimal)interestRate
- 100.0M;
}
///
/// Return a text string that represents this account
/// for output purposes
///
public override string ToString() {
return owner + "'s check account holds " +
+ balance + " kroner";
}
}