-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddRotatingGearAction.cpp
More file actions
53 lines (39 loc) · 1.36 KB
/
Copy pathAddRotatingGearAction.cpp
File metadata and controls
53 lines (39 loc) · 1.36 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
#include "AddRotatingGearAction.h"
AddRotatingGearAction::AddRotatingGearAction(ApplicationManager * pApp):Action(pApp)
{
}
void AddRotatingGearAction::ReadActionParameters()
{
///TODO: Implement this function as mentioned in the guideline steps (numbered below) below
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Click on the cell to place the rotating gear...");
gearPos = pIn->GetCellClicked();
if (!gearPos.IsValidCell()) {
pOut->PrintMessage("Invalid cell! Click anywhere to continue.");
pIn->GetCellClicked();
return;
}
pOut->ClearStatusBar();
// == Here are some guideline steps (numbered below) to implement this function ==
// 1- Get a Pointer to the Input / Output Interfaces
// 2- Read the gearPos
// 3- Read whether the direction will be clockwise or not
// 4- Make the needed validations on the read parameters
// 5- Clear status bar
}
void AddRotatingGearAction::Execute()
{
ReadActionParameters();
RotatingGear* pGear = new RotatingGear(gearPos, clockwise);
Grid* pGrid = pManager->GetGrid();
bool added = pGrid->AddObjectToCell(pGear);
if (!added) {
delete pGear;
pGrid->PrintErrorMessage("Error: Cell already has an object! Click to continue...");
}
}
AddRotatingGearAction::~AddRotatingGearAction()
{
}