-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus.h
128 lines (122 loc) · 3.34 KB
/
bus.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* @file bus.h
*
* @copyright 2019 3081 Staff, All rights reserved.
*/
#ifndef SRC_BUS_H
#define SRC_BUS_TYPES_H
#include <iostream>
#include <list>
#include <string>
#include "src/data_structs.h"
#include "src/IObservable.h"
#include "src/passenger.h"
#include "src/passenger_loader.h"
#include "src/passenger_unloader.h"
#include "src/route.h"
#include "src/stop.h"
class PassengerUnloader;
class PassengerLoader;
class Route;
class Stop;
class Bus : public IObservable<BusData*> {
public:
Bus(std::string name, Route * out, Route * in, int capacity = 60,
double speed = 1, std::string type = "Medium");
/**
* @brief Get passengers on bus
*
* @return boolean
*/
bool IsTripComplete();
/**
* @brief check if bus is current at incoming or outgoing route
*
* @return route
*/
bool LoadPassenger(Passenger *); // returning revenue delta
/**
* @brief Get passengers off the bus with they reach their destination
*
* @return integer
*/
bool Move();
/**
* @brief check if bus has complete its outgoing and incoming route
*
* @return boolean
*/
void Update();
/**
* @brief Print bus information and status
*/
void Report(std::ostream&);
/**
* @brief Print bus information and status
* called by the visualizer to instruct
* the bus object to populate the BusData
* struct with the latest information
* (see the file data_structs.h to
* determine what information the BusData
* struct stores.). This a nontivial
* method, so we will outline its operation
* (which you have to implement), below.
*/
// Vis Getters
void UpdateBusData();
/**
* @brief called by the visualizer to get then
* name of the bus
*/
BusData GetBusData() const;
/**
* @brief called by the visualizer to get then
* name of the bus
*/
std::string GetName() const { return name_; }
/**
* @brief called by the visualizer to get the pointer
* to the bus's next stop
*/
Stop * GetNextStop() const { return next_stop_; }
/**
* @brief called by the visualizer to get the current
* number of passengers on the bus
*/
size_t GetNumPassengers() const { return passengers_.size(); }
/**
* @brief called by the visualizer to get the current
* number of passengers on the bus
*/
int GetCapacity() const { return passenger_max_capacity_; }
private:
int UnloadPassengers(); // returning revenue delta
int HandleBusStop();
void ToNextStop();
double UpdateDistance();
Route* CurrentRoute();
// bool Refuel();
PassengerUnloader * unloader_;
PassengerLoader * loader_;
std::list<Passenger *> passengers_;
int passenger_max_capacity_;
// double revenue_; // revenue collected from passengers, doesn't include
// passengers who pay on deboard
// double fuel_; // may not be necessary for our simulation
// double max_fuel_;
std::string name_;
std::string type_;
double speed_; // could also be called "distance travelled in one time step"
Route * outgoing_route_;
Route * incoming_route_;
double distance_remaining_; // when negative?, unload/load procedure occurs
// AND next stop set
Stop * next_stop_;
// bool trip_complete_; // [DERIVED data] when BOTH routes are at end, trip
// is complete
// Vis data for bus
BusData bus_data_;
protected:
int total_passengers;
};
#endif // SRC_BUS_H_