diff options
Diffstat (limited to 'DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs')
| -rw-r--r-- | DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs b/DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs new file mode 100644 index 0000000..4afe62a --- /dev/null +++ b/DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs @@ -0,0 +1,44 @@ +namespace DesignPatterns.State {
+ public class PosTerminal : IPosTerminal {
+ public PosTerminal( ) {
+ _currentState = new IdleState( this );
+ }
+
+ public IState CurrentState {
+ get { return _currentState; }
+ set { _currentState = value; }
+ }
+
+ public IPosTransaction Transaction {
+ get { return _transaction; }
+ set { _transaction = value; }
+ }
+
+ public void SwipeCard( string cardNumber ) {
+ _currentState.SwipeCard( cardNumber );
+ }
+
+ public void EnterAmount( double amount ) {
+ _currentState.EnterAmount( amount );
+ }
+
+ public void EnterPin( string pin ) {
+ _currentState.EnterPin( pin );
+ }
+
+ public void AuthorizeTransaction( ) {
+ _currentState.ProcessTransaction( );
+ }
+
+ public void PrintReceipt( ) {
+ _currentState.PrintReceipt( );
+ }
+
+ public void ProcessTransaction( ) {
+ _currentState.ProcessTransaction( );
+ }
+
+ private IState _currentState;
+ private IPosTransaction _transaction;
+ }
+}
\ No newline at end of file |
