回答編集履歴

1

Worldにも追加

2023/03/25 07:00

投稿

matukeso
matukeso

スコア1590

test CHANGED
@@ -1 +1,9 @@
1
1
  その例ならbool Point::isInRect(Point, Point)を追加すれば良いでしょ。
2
+ 追記:Worldにも似たようなメソッドがいるよ。
3
+ ```cpp
4
+ bool Point::isInRect(Point lu, Point rd) const { return lu.m_x < m_x && m_x < rd.m_x && lu.m_y < m_y && m_y < rd.m_y; }
5
+ bool World::isPointInside( Point pt ) const { return pt.isInRect( m_start, m_end ); }
6
+ bool Player::isInWorld(World world) const { return world.isPointInside(m_point); }
7
+ ```
8
+
9
+ #Point自体からはあんまし「オブジェクト」って感じはしないんで、getter足してもいいと思うけどねぇ。