Listing 5
using namespace System;
public ref class Transfer sealed : Transaction
{
Decimal amount;
int fromAccount;
int toAccount;
public:
Transfer(double amount, int fromAccount, int toAccount)
: Transaction(TransactionType::Transfer)
{
TransferAmount = Decimal(amount);
TransferFromAccount = fromAccount;
TransferToAccount = toAccount;
}
Transfer(Decimal amount, int fromAccount, int toAccount)
: Transaction(TransactionType::Transfer)
{
TransferAmount = amount;
TransferFromAccount = fromAccount;
TransferToAccount = toAccount;
}
property Decimal TransferAmount
{
Decimal get() { return amount; };
private:
void set(Decimal value) { amount = value; };
}
property int TransferFromAccount
{
int get() { return fromAccount; };
private:
void set(int value) { fromAccount = value; };
}
property int TransferToAccount
{
int get() { return toAccount; };
private:
void set(int value) { toAccount = value; };
}
void Transfer::PostTransaction()
{
Console::WriteLine("{0} -- {1}", DateTimeOfTransaction, this);
}
virtual String^ ToString() override
{
return String::Format("Xfer: {0,10:0.00} {1,10} {2,10}",
TransferAmount, TransferToAccount, TransferFromAccount);
}
};