-
Notifications
You must be signed in to change notification settings - Fork 1
/
Truck.h
97 lines (65 loc) · 2.42 KB
/
Truck.h
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
#ifndef GAMESIMULATOR_TRUCK_H
#define GAMESIMULATOR_TRUCK_H
#include <vector>
#include "Vehicle.h"
using routesVec = vector <pair<string, pair<double, int> > >;
using timeVec = vector< pair<string,string> >;
/**
* Truck class
* One of the simulator object.
* No need for the implementation of the "Big Five".
* **/
class Truck: public Vehicle{
private:
int _crates;
routesVec _routes; // vector < destination name: (time,crates) >
timeVec _times; // vector < arriveTime, LeaveTime >
int _index;
public:
// Constructor
Truck(string &name, const Point& location, string vType): Vehicle(name,location,vType),_crates(0), _index(0) {Vehicle::setState("Moving");};
// The function will look around for State Troopers
// in the range of 10 KM.
bool checkCops();
// Sets the Truck into "Robbed" mode.
// The inventory will be gone and the truck state will turn to "OffRoad".
void robbed();
// Calculate the speed of the Truck per hour.
void calcSpeed();
// Calculate the angle of the current Truck course.
void calcCourse();
// initializes the trucks details.
void init();
//updates the location and movement of the truck.
void update() override;
// Updates the inventory of the truck after it reaches the warehouse
void updateInventory();
// updated the inventories after arriving at a warehouse.
void arrived();
// updates the next location of the truck, if it finishes the truck state will turn into "OffRoad".
void updateIndex();
// calculates the time left for travel after arriving at a warehouse.
double calcTimeLeft(int time);
//returns the next destination warehouse.
warehousePtr getNextDest();
//true if needs to leave a warehouse at the current time.
bool needToMove();
// return true if object need to stay, false otherwise.
bool stay();
// starts to move after parking state.
void startMove();
// checks whether the next warehouse location is in the same hour.
bool inRange(int arriveTime);
// true if finished all the visits.
bool done();
/**
* Setters and Getters
*/
int getCrates() const { return _crates; }
void setRoutes(const routesVec &routes);
void setTimes(const timeVec & times);
void setCrates(int crates) { _crates = crates;}
void getStatus() override;
warehousePtr getCurrentWarehouse();
};
#endif //GAMESIMULATOR_TRUCK_H