-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteAction.cpp
More file actions
40 lines (37 loc) · 1.15 KB
/
Copy pathDeleteAction.cpp
File metadata and controls
40 lines (37 loc) · 1.15 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
#include "DeleteAction.h"
#include "Card.h"
DeleteAction::DeleteAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
DeleteAction::~DeleteAction()
{
}
void DeleteAction::ReadActionParameters()
{
// 1- Get a Pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
// 2- Read the "cardNumber" parameter and set its data member
pOut->PrintMessage("Delete : Click on card that you want to delete ...");
cardPosition = pIn->GetCellClicked();
// 3- Clear status bar
pOut->ClearStatusBar();
}
void DeleteAction::Execute()
{
// 1- The first line of any Action Execution is to read its parameter first
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
if (cardPosition.IsValidCell())
{
pGrid->RemoveObjectFromCell(cardPosition);//removing
pOut->PrintMessage("Cell Object must have been removed (if not make sure you clicked on the right cell), Click to continue ...");
}
else
{
pOut->PrintMessage("you have not choosen a valid cell, Click to continue ...");
}
}