code: def add_leg(self, leg):
          
          assert(isinstance(leg, Connection))
          if not self.legs:
              self.departure_time = leg.departure_time
          self.arrival_time = leg.arrival_time
          if leg.trip_id and (not self.legs or (leg.trip_id != self.legs[-1].trip_id)):
              self.n_boardings += 1
          self.arrival_time = leg.arrival_time
          self.legs.append(leg)
docs: Parameters
          ----------
          leg: Connection