blob: cfedf2d897bb0d36f9c654cd5bfdae14ab0f83e1 (
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
|
using System;
namespace DesignPatterns.State {
public class TransactionApprovedState : IState {
public TransactionApprovedState( IPosTerminal terminal ) {
_terminal = terminal;
}
public void SwipeCard( string cardNumber ) {
Console.Out.WriteLine( "The transaction was approved" );
}
public void EnterAmount( double amount ) {
Console.Out.WriteLine( "The transaction was approved" );
}
public void EnterPin( string pin ) {
Console.Out.WriteLine( "The transaction was approved" );
}
public void ProcessTransaction( ) {
Console.Out.WriteLine( "The transaction was approved" );
}
public void PrintReceipt( ) {
Console.Out.WriteLine( "** Approved **" );
Console.Out.WriteLine( "Date: {0}", _terminal.Transaction.Date );
Console.Out.WriteLine( "Card Number: {0}", _terminal.Transaction.CardNumber );
Console.Out.WriteLine( "Amount: {0}", _terminal.Transaction.Amount );
_terminal.CurrentState = new IdleState( _terminal );
}
private IPosTerminal _terminal;
}
}
|