using System;
namespace Assignment_1B
{
public class Account
{
// To do - declare all class data members as properties (ID, Name and Value
public int ID { get; set; }
public string Name { get; set; }
public double Value { get; set; } = 0.0;
public virtual void Deposit(double amount)
{
Value += amount;
}
public virtual void Withdraw(double amount)
{
Value -= amount;
}
}
public class SavingsAccount : Account
{
public double InterestRate { get; set; }
public void MonthEnd()
{
Value += Value * InterestRate;
}
}
public class CheckingAccount : Account
{
public int TransactionLimit { get; set; }
public int TransactionCount { get; private set; }
public double TransactionFee { get; set; }
public double AccountFee { get; set; }
public override void Deposit(double amount)
{
Value += amount;
}
public override void Withdraw(double amount)
{
Value -= amount;
}
private void UpdateTransectionCount()
{
Value = TransactionLimit - TransactionCount;
}
public void MonthEnd()
{
Value = Value - ((TransactionLimit * TransactionFee)+AccountFee);
}
}
class Program
{
static void Main(string[] args)
{
var mySavingsAccount = new SavingsAccount { ID = 5, Name = "My Savings Account", InterestRate = 0.01 };
mySavingsAccount.Deposit(100.0);
mySavingsAccount.Withdraw(20.0);
Console.WriteLine("Current Balance after all transections (Savings Account): " + mySavingsAccount.Value);
mySavingsAccount.MonthEnd();
Console.WriteLine("Balance after month end (Savings Account): " + mySavingsAccount.Value);
var myCheckingAccount = new CheckingAccount { ID = 7, Name = "My Checking Account", TransactionLimit = 2, TransactionFee = 1.5, AccountFee = 5.0 };
myCheckingAccount.Deposit(100.0);
myCheckingAccount.Withdraw(10.0);
myCheckingAccount.Withdraw(10.0);
myCheckingAccount.Withdraw(10.0);
myCheckingAccount.Deposit(100.0);
myCheckingAccount.Withdraw(20.0);
Console.WriteLine("Current Balance after all transections (Checking Account): " + myCheckingAccount.Value);
myCheckingAccount.MonthEnd();
Console.WriteLine("Balance after month end (Checking Account):" + myCheckingAccount.Value);
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}