using System;
using System.Collections.Generic;
using System.Text;
namespace Wrox.ProCSharp
{
public interface IBankAccount
{
void PayIn(decimal amount); //存款的方法
bool Withdraw(decimal amount); //判断是否余款不足
decimal Balance //返回余款的属性
{
get;
}
}
public interface ITransferBankAccount : IBankAccount
{
bool TransferTo(IBankAccount destination, decimal amount);
}
public class CurrentAccount : ITransferBankAccount
{
private decimal balance;
public void PayIn(decimal amount)
{
balance += amount;
}
public bool Withdraw(decimal amount)
{
if (balance > = amount)
{
balance -= amount;
return true;
}
Console.WriteLine( "转帐失败 ");
return false;
}
public decimal Banlance
{
get
{
return balance;
}