State Pattern Code Review
Use the State Pattern
Code Review
- State Pattern Code Review: Define the Pattern Interface and Handler Objects
- State Pattern Code Review: Define the Context Object
- State Pattern Code Review: Use the State Pattern
Code Walkthrough
The Program class creates the Context object invokes methods on the Context class (object).
class Program
{
static void Main(string[] args)
{
Context context = new Context("Jim Johnson");
context.Deposit(500.00); context.PayInterest(); context.Deposit(300.00); context.Deposit(550.00); context.PayInterest(); context.Withdraw(2000.00); context.Withdraw(1100.00);
Console.Read(); } }
context.Deposit(500.00); context.PayInterest(); context.Deposit(300.00); context.Deposit(550.00); context.PayInterest(); context.Withdraw(2000.00); context.Withdraw(1100.00);
Console.Read(); } }
Printer Friendly Version
Add to Favourites
DotNet Kicks
Digg
del.icio.us
Live Favourites
ma.gnolia
reddit
Slashdot
Technorati
Yahoo!