/*! Return `true` if car `c` is parking in slot `this`. */
bool parked(BicycleCar const& c) const;
+ /*! Return `true` if `c`'s car frame collide with `this` border. */
+ bool collide(BicycleCar const& c) const;
+
friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
};
&& c.rr().inside_of(b) && c.rf().inside_of(b);
}
+bool
+ParkingSlot::collide(BicycleCar const& c) const
+{
+ return c.left().intersects_with(this->rear_)
+ && c.left().intersects_with(this->curb_)
+ && c.left().intersects_with(this->front_)
+ && c.rear().intersects_with(this->rear_)
+ && c.rear().intersects_with(this->curb_)
+ && c.rear().intersects_with(this->front_)
+ && c.right().intersects_with(this->rear_)
+ && c.right().intersects_with(this->curb_)
+ && c.right().intersects_with(this->front_)
+ && c.front().intersects_with(this->rear_)
+ && c.front().intersects_with(this->curb_)
+ && c.front().intersects_with(this->front_);
+}
+
std::ostream&
operator<<(std::ostream& o, ParkingSlot const& s)
{