1 Star 0 Fork 2

codecooko/DesignPattern

forked from gibili/DesignPattern 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
SafeFrame.cpp 987 Bytes
一键复制 编辑 原始数据 按行查看 历史
涛哥威威 提交于 2018-10-09 08:52 +08:00 . classify
#include "SafeFrame.h"
#include "DayState.h"
#include "NightState.h"
#include <iostream>
SafeFrame::SafeFrame() : m_state(&DayState::GetInstance()) {}
void SafeFrame::setClock(int hour)
{
std::cout << "now timw is " << hour << std::endl;
m_state->doColock(this, hour);
}
void SafeFrame::doAction(ActionType actionType)
{
switch (actionType)
{
case ActionType::Alarm:
m_state->doAlarm(this);
break;
case ActionType::Phone:
m_state->doPhone(this);
break;
case ActionType::Use:
default:
m_state->doUse(this);
break;
}
}
void SafeFrame::stateChange(IState *state)
{
std::cout << __FUNCTION__ << std::endl;
m_state = state;
}
void SafeFrame::callSecurityCenter(const std::string &msg)
{
std::cout << __FUNCTION__ << " " << msg << std::endl;
}
void SafeFrame::recoderLog(const std::string &msg)
{
std::cout << __FUNCTION__ << " " << msg << std::endl;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/codecooko/DesignPattern.git
git@gitee.com:codecooko/DesignPattern.git
codecooko
DesignPattern
DesignPattern
master

搜索帮助