传入参数有什么好处?我们可以从中获得什么?目的是什么?
interface IBankAccount
{
void PayIn(decimal amount);
bool Withdraw(decimal amount);
decimal Balance { get; }
}
interface ITransferBankAccount : IBankAccount
{
bool TranferTo(IBankAccount destination, decimal amount);
}
class CurrentAccount : ITransferBankAccount
{
public bool TranferTo(IBankAccount destination, decimal amount)
{
bool result;
result = Withdraw(amount);
if (result)
{
destination.PayIn(amount);
}
return result;
}
public decimal Balance
{
get
{
throw new NotImplementedException();
}
}
public void PayIn(decimal amount)
{
throw new NotImplementedException();
}
public bool Withdraw(decimal amount)
{
throw new NotImplementedException(); …Run Code Online (Sandbox Code Playgroud)