summaryrefslogtreecommitdiff
path: root/DesignPatterns/src/app/DesignPatterns.State/PosTerminal.cs
blob: 4afe62ac38375a58c0f275a987d1f2aeb5029b2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
	}
}