-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCancelEvent.cpp
43 lines (37 loc) · 876 Bytes
/
CancelEvent.cpp
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
#include "CancelEvent.h"
#include "Company.h"
#include <iostream>
using namespace std;
bool CancelEvent::Execute(Company& Comp)
{
//removing the cargo from waiting normal by ID list if found
bool Check = true;
if (Comp.GetNormalLoadingTruck())
{
int Index = Comp.GetWaitingIndex(ID);
int Cap;
Truck* TempTruck;
TempTruck = Comp.GetNormalLoadingTruck();
if (dynamic_cast<NormalTruck*>(TempTruck))
Cap = NormalTruck::GetTruckCapacity();
if (dynamic_cast<VIPTruck*>(TempTruck))
Cap = VIPTruck::GetTruckCapacity();
Check = Cap - TempTruck->GetCargoCount() < Index;
}
if (Check)
{
Cargo* CargoToBeDeleted = Comp.RemoveWNC(ID);
//checking whether it was found or not
if (CargoToBeDeleted)
{
//deallocating the cargo
delete CargoToBeDeleted;
return true;
}
return false;
}
}
void CancelEvent::SetParameters(int id)
{
ID = id;
}