-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete.cpp
More file actions
45 lines (37 loc) · 947 Bytes
/
Copy pathDelete.cpp
File metadata and controls
45 lines (37 loc) · 947 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
36
37
38
39
40
41
42
43
44
45
#include "Delete.h"
#include "Action.h"
#include "Grid.h"
#include "CellPosition.h"
void Delete::ReadActionParameters()
{
Grid* pGride = pManager->GetGrid();
Input* pInput = pGride->GetInput();
pGride->GetOutput()->PrintMessage("Click on Cell to Delete");
deletedcell = pInput->GetCellClicked();
if (!deletedcell.IsValidCell()) //checks if the cell is valid
{
pGride->PrintErrorMessage("The Cell is invalid");
return;
}
}
void Delete::Execute()
{
Grid* pGride = pManager->GetGrid();
ReadActionParameters();
if (!deletedcell.IsValidCell()) //checks if the cell is valid
{
pGride->PrintErrorMessage("The Cell is invalid");
return;
}
if (pGride->RemoveObjectFromCell(deletedcell)) //removes the object
{
pGride->GetOutput()->PrintMessage("The Object deleted successfully");
}
else
{
pGride->PrintErrorMessage("The Object deleted Failed");
}
}
Delete::~Delete()
{
}