mirror of
https://gitee.com/yanmu_ym/cpp.git
synced 2026-02-04 10:03:15 +08:00
MAKE
This commit is contained in:
36
Make/sudoku/command.cpp
Normal file
36
Make/sudoku/command.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "scene.h"
|
||||
#include "command.h"
|
||||
|
||||
CCommand::CCommand(CScene *pOwner) : _pOwner(pOwner)
|
||||
{}
|
||||
|
||||
CCommand::CCommand(CScene *pOwner, const point_t &point, int preValue, int curValue)
|
||||
: _pOwner(pOwner), _stPoint(point), _nPreValue(preValue), _nCurValue(curValue) {}
|
||||
|
||||
CCommand::CCommand(const CCommand &rhs)
|
||||
: _pOwner(rhs._pOwner)
|
||||
, _stPoint(rhs._stPoint)
|
||||
, _nPreValue(rhs._nPreValue)
|
||||
, _nCurValue(rhs._nCurValue)
|
||||
{}
|
||||
|
||||
CCommand::~CCommand(){}
|
||||
|
||||
bool CCommand::execute(int nInputValue)
|
||||
{
|
||||
if (!_pOwner)
|
||||
return false;
|
||||
|
||||
_stPoint = _pOwner->getCurPoint();
|
||||
return _pOwner->setCurValue(nInputValue, _nPreValue);
|
||||
}
|
||||
|
||||
void CCommand::undo()
|
||||
{
|
||||
if (_pOwner)
|
||||
{
|
||||
_pOwner->setPointValue(_stPoint, _nPreValue);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user