forked from me115/design_patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConcreteStateB.cpp
More file actions
36 lines (28 loc) · 786 Bytes
/
ConcreteStateB.cpp
File metadata and controls
36 lines (28 loc) · 786 Bytes
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
///////////////////////////////////////////////////////////
// ConcreteStateB.cpp
// Implementation of the Class ConcreteStateB
// Created on: 09-十月-2014 17:20:59
// Original author: colin
///////////////////////////////////////////////////////////
#include "ConcreteStateB.h"
#include "ConcreteStateA.h"
#include "Context.h"
#include <iostream>
using namespace std;
State * ConcreteStateB::m_pState = NULL;
ConcreteStateB::ConcreteStateB(){
}
State * ConcreteStateB::Instance()
{
if ( NULL == m_pState)
{
m_pState = new ConcreteStateB();
}
return m_pState;
}
ConcreteStateB::~ConcreteStateB(){
}
void ConcreteStateB::handle(Context * c){
cout << "doing something in State B.\n done,change state to A" << endl;
c->changeState(ConcreteStateA::Instance());
}