#ifndef BICYCLE_H #define BICYCLE_H #include "Vehicle.h" #include #include using namespace std; template class Bicycle : public Vehicle { public: Bicycle(); Bicycle(int, int, string, int); //set x, y, name and capacity (remember that capacity can be at most 2) ~Bicycle(); //Redefined functions inherited from Vehicle void move(int, int); // move to the requested x, y location divided by 2 void set_capacity(int); // set the capacity value; can't be larger than 2 }; //Add default constructor //Include: cout << "Creating new bicyle " << this->name << endl; template Bicycle::Bicycle() { this->x_pos = 0; this->y_pos = 0; this->name = "Default"; this->capacity = 1; this->current_passenger = -1; this->passengers = new T[this->capacity]; cout << "Creating new bicyle " << this->name << endl; } //Add constructor //Include: cout << "Creating new bicyle " << this->name << endl; template Bicycle::Bicycle(int x, int y, string n, int c) : Vehicle() { this->x_pos = x; this->y_pos = y; this->name = n; this->capacity = c > 2 ? 2 : c; this->current_passenger = -1; this->passengers = new T[this->capacity]; cout << "Creating new bicyle " << this->name << endl; } //Add destructor //Include: cout << "Destroyed a bicycle named: " << this->name << endl; template Bicycle::~Bicycle() { cout << "Destroyed a bicycle named: " << this->name << endl; } //Add move function //Include: cout << "Moving to bicycle " << this->name << " to x: " << this->x_pos << " y: " << this->y_pos << endl; template void Bicycle::move(int x, int y) { this->x_pos = x/2; this->y_pos = y/2; cout << "Moving to bicycle " << this->name << " to x: " << this->x_pos << " y: " << this->y_pos << endl; } //Add capacity function //Include: cout << "Setting bicycle " << this->name << " to " << this->capacity << endl; template void Bicycle::set_capacity(int c) { int n = c > 2 ? 2 : c<0?-c:c; Vehicle::set_capacity(n); cout << "Setting bicycle " << this->name << " to " << this->capacity << endl; } #endif