+void Train::set_priority(int p)
+{
+ priority = p;
+}
+
+void Train::yield_to(const Train &t)
+{
+ yielding_to = &t;
+}
+
+void Train::add_vehicle(const VehicleType &vt)
+{
+ 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();
+}
+