blob: ec27fdc54c2970ab0379bc1492c9b426e0b5aad9 (
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
|
using System;
namespace DesignPatterns.State {
public class AmountEnteredState : IState {
public AmountEnteredState( 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 ) {
_terminal.Transaction.Pin = pin;
_terminal.CurrentState = new PinEnteredState( _terminal );
}
public void ProcessTransaction( ) {
Console.Out.WriteLine( "You haven't entered an amount yet." );
}
public void PrintReceipt( ) {
Console.Out.WriteLine( "You haven't entered an amount yet." );
}
private IPosTerminal _terminal;
}
}
|