-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCutCardAction.cpp
More file actions
65 lines (44 loc) · 1.43 KB
/
CutCardAction.cpp
File metadata and controls
65 lines (44 loc) · 1.43 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "CutCardAction.h"
#include "Input.h"
#include "Output.h"
#include "Card.h"
CutCardAction::CutCardAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
CutCardAction::~CutCardAction()
{
}
void CutCardAction::ReadActionParameters()
{
// Get a Pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
// Read the position parameter
pOut->PrintMessage("click on the source cell");
cardposition = pIn->GetCellClicked();
/// Make the needed validations on the read parameters
if (cardposition.GetCellNum() == -1)
{
pGrid->PrintErrorMessage("cancel operation:invalid cell position,click anywhere to continue");
}
// Clear messages
pOut->ClearStatusBar();
}
// Execute the action
void CutCardAction::Execute()
{
// The first line of any Action Execution is to read its parameter first
// and hence initializes its data members
ReadActionParameters();
// Create a card object with the parameters read from the user
Grid* pGrid = pManager->GetGrid(); // We get a pointer to the Grid from the ApplicationManager
if (cardposition.GetCellNum() == -1)
return;
if (pGrid->GetCard(cardposition))
{
pGrid->SetClipboard(pGrid->GetCard(cardposition));
pGrid->RemoveObjectFromCell(cardposition);
}
}