Listing 4
using namespace System;
public ref class Withdrawal sealed : Transaction
{
Decimal amount;
int fromAccount;
public:
Withdrawal(double amount, int fromAccount) :
Transaction(TransactionType::Withdrawal)
{
WithdrawalAmount = Decimal(amount);
WithdrawalFromAccount = fromAccount;
}
Withdrawal(Decimal amount, int fromAccount) :
Transaction(TransactionType::Withdrawal)
{
WithdrawalAmount = amount;
WithdrawalFromAccount = fromAccount;
}
property Decimal WithdrawalAmount
{
Decimal get() { return amount; };
private:
void set(Decimal value) { amount = value; };
}
property int WithdrawalFromAccount
{
int get() { return fromAccount; };
private:
void set(int value) { fromAccount = value; };
}
void PostTransaction()
{
Console::WriteLine("{0} -- {1}", DateTimeOfTransaction, this);
}
virtual String^ ToString() override
{
return String::Format("With: {0,10:0.00} {1,10}",
WithdrawalAmount, WithdrawalFromAccount);
}
};