|
namespace Bddify.Samples.Atm
{
public class Atm
{
public int ExistingCash { get; private set; }
public Atm(int existingCash)
{
ExistingCash = existingCash;
}
public void RequestMoney(Card card, int request)
{
if (!card.Enabled)
{
CardIsRetained = true;
Message = DisplayMessage.CardIsRetained;
return;
}
if(card.AccountBalance < request)
{
Message = DisplayMessage.InsufficientFunds;
return;
}
DispenseValue = request;
card.AccountBalance -= request;
}
public int DispenseValue { get; set; }
public bool CardIsRetained { get; private set; }
public DisplayMessage Message { get; private set; }
}
public class Card
{
public int AccountBalance { get; set; }
private readonly bool _enabled;
public Card(bool enabled, int accountBalance)
{
AccountBalance = accountBalance;
_enabled = enabled;
}
public bool Enabled
{
get { return _enabled; }
}
}
public enum DisplayMessage
{
None = 0,
CardIsRetained,
InsufficientFunds
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.