-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasteAction.cpp
More file actions
118 lines (113 loc) · 3.52 KB
/
Copy pathPasteAction.cpp
File metadata and controls
118 lines (113 loc) · 3.52 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include "PasteAction.h"
#include "Card.h"
#include "Card1.h"
#include "Card2.h"
#include "Card3.h"
#include "Card4.h"
#include "Card5.h"
#include "Card6.h"
#include "Card7.h"
#include "Card8.h"
#include "Card9.h"
#include "CardM10.h"
#include "CardM11.h"
#include "CardM12.h"
#include "CardM13.h"
PasteAction::PasteAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
PasteAction::~PasteAction()
{
}
void PasteAction::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("Paste : Click on cell that you want to Paste ...");
cardPosition = pIn->GetCellClicked();
// 5- Clear status bar
pOut->ClearStatusBar();
}
void PasteAction::Execute()
{
// 1- The first line of any Action Execution is to read its parameter first
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Card* pCard = NULL;
if (cardPosition.IsValidCell())
{
if (pGrid->GetClipboard())
{
switch ((pGrid->GetClipboard())->GetCardNumber())
{
case 1:
pCard = new Card1(cardPosition);
dynamic_cast<Card1*>(pCard)->SetWalletAmount(dynamic_cast<Card1*>(pGrid->GetClipboard())->GetWalletAmount());
break;
case 2:
pCard = new Card2(cardPosition);
dynamic_cast<Card2*>(pCard)->SetWalletAmount(dynamic_cast<Card2*>(pGrid->GetClipboard())->GetWalletAmount());
break;
case 3:
pCard = new Card3(cardPosition);
break;
case 4:
pCard = new Card4(cardPosition);
break;
case 5:
pCard = new Card5(cardPosition);
break;
case 6:
pCard = new Card6(cardPosition);
break;
case 7:
pCard = new Card7(cardPosition);
break;
case 8:
pCard = new Card8(cardPosition);
break;
case 9:
pCard = new Card9(cardPosition);
dynamic_cast<Card9*>(pCard)->SetToCellNum(dynamic_cast<Card9*>(pGrid->GetClipboard())->GetToCellNum());
break;
case 10:
pCard = new CardM10(cardPosition);
dynamic_cast<CardM10*>(pCard)->SetPrice(dynamic_cast<CardM10*>(pGrid->GetClipboard())->GetPrice());
dynamic_cast<CardM10*>(pCard)->SetFees(dynamic_cast<CardM10*>(pGrid->GetClipboard())->GetFees());
break;
case 11:
pCard = new CardM11(cardPosition);
dynamic_cast<CardM11*>(pCard)->SetPrice(dynamic_cast<CardM11*>(pGrid->GetClipboard())->GetPrice());
dynamic_cast<CardM11*>(pCard)->SetFees(dynamic_cast<CardM11*>(pGrid->GetClipboard())->GetFees());
break;
case 12:
pCard = new CardM12(cardPosition);
dynamic_cast<CardM12*>(pCard)->SetPrice(dynamic_cast<CardM12*>(pGrid->GetClipboard())->GetPrice());
dynamic_cast<CardM12*>(pCard)->SetFees(dynamic_cast<CardM12*>(pGrid->GetClipboard())->GetFees());
break;
case 13:
pCard = new CardM13(cardPosition);
dynamic_cast<CardM13*>(pCard)->SetPrice(dynamic_cast<CardM13*>(pGrid->GetClipboard())->GetPrice());
dynamic_cast<CardM13*>(pCard)->SetFees(dynamic_cast<CardM13*>(pGrid->GetClipboard())->GetFees());
break;
// A- Add the remaining cases
//done all were added
}
pGrid->AddObjectToCell(pCard);
pOut->PrintMessage("Card cell have been pasted, Click to continue ...");
}
else
{
pOut->PrintMessage("you have not pasted a card cell (check if you have copied a one), Click to continue ...");
}
}
else
{
pOut->PrintMessage("you have not choosen a valid cell, Click to continue ...");
}
}