summaryrefslogtreecommitdiff
path: root/DesignPatterns/src/app/DesignPatterns.State/PinEnteredState.cs
blob: 809186a1806d1470d8a6975c6fe673f26671749a (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
using System;

namespace DesignPatterns.State {
	public class PinEnteredState : IState {
		public PinEnteredState( IPosTerminal terminal ) {
			_terminal = terminal;
		}

		public void SwipeCard( string cardNumber ) {
			Console.Out.WriteLine( "You've already swiped a card." );
		}

		public void EnterAmount( double amount ) {
			Console.Out.WriteLine( "You've already entered an amount." );
		}

		public void EnterPin( string pin ) {
			Console.Out.WriteLine( "You've already entered a pin." );
		}

		public void ProcessTransaction( ) {
			_terminal.CurrentState = new ProcessingTransactionState( _terminal );
		}

		public void PrintReceipt( ) {
			Console.Out.WriteLine( "The transaction needs to be authorized first" );
		}

		private IPosTerminal _terminal;
	}
}