-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoinSet.cpp
More file actions
48 lines (44 loc) · 1023 Bytes
/
Copy pathCoinSet.cpp
File metadata and controls
48 lines (44 loc) · 1023 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
46
47
48
#include "CoinSet.h"
#include "Player.h"
#include<iostream>
#include <fstream>
using namespace std;
//done by (noha)
void CoinSet::setAmount(int c) {
amount = c;
}
int CoinSet::getAmount() {
return amount;
}
void CoinSet::Draw(Output* pOut)const {
pOut->DrawCoinSet(position);
}
void CoinSet::Apply(Grid* pGrid, Player* pPlayer) {
pPlayer->SetWallet(amount+pPlayer->GetWallet());
pGrid->UpdateInterface();
}
CoinSet::CoinSet(int x, CellPosition pos) : GameObject(pos)
{
amount = x;
}
void CoinSet::SetPosition(CellPosition cpos)
{
position = cpos;
}
void CoinSet::SaveToFile(ofstream& output, int obj) {
if (obj == 4) {
GameObject::SaveToFile(output, obj);
int amount = this->getAmount();
output << " " << amount << std::endl;
}
}
void CoinSet::getCoinPtr(int num, ifstream& inputFile, Grid* newGrid) {
int i = 0;
while (i < num) {
int cellNum, amount;
inputFile >> cellNum >> amount;
CoinSet* newCoin = new CoinSet(amount, CellPosition(cellNum));
newGrid->AddObjectToCell(newCoin);
i++;
}
}