+ Vehicle *veh = new Vehicle(layout, vt);
+ vehicles.back()->attach_back(*veh);
+ vehicles.push_back(veh);
+}
+
+void Train::remove_vehicle(unsigned i)
+{
+ if(i>=vehicles.size())
+ throw InvalidParameterValue("Vehicle index out of range");
+ if(i==0)
+ throw InvalidParameterValue("Can't remove the locomotive");
+ delete vehicles[i];
+ vehicles.erase(vehicles.begin()+i);
+ if(i<vehicles.size())
+ vehicles[i-1]->attach_back(*vehicles[i]);
+}
+
+unsigned Train::get_n_vehicles() const
+{
+ return vehicles.size();
+}
+
+Vehicle &Train::get_vehicle(unsigned i)
+{
+ if(i>=vehicles.size())
+ throw InvalidParameterValue("Vehicle index out of range");
+ return *vehicles[i];
+}
+
+const Vehicle &Train::get_vehicle(unsigned i) const
+{
+ if(i>=vehicles.size())
+ throw InvalidParameterValue("Vehicle index out of range");
+ return *vehicles[i];
+}
+
+void Train::set_control(const string &n, float v)
+{
+ controller->set_control(n, v);
+}
+
+void Train::set_active(bool a)
+{
+ if(a==active)