From 31d82d2a9501ccf9598d93cdc41519d1147e6d3d Mon Sep 17 00:00:00 2001 From: ekallin Date: Sun, 8 Oct 2023 20:49:50 +0400 Subject: [PATCH] ObjectParameters class completed --- ObjectParameters.java | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 ObjectParameters.java diff --git a/ObjectParameters.java b/ObjectParameters.java new file mode 100644 index 0000000..0573525 --- /dev/null +++ b/ObjectParameters.java @@ -0,0 +1,50 @@ +public class ObjectParameters { + private final int _x; + private final int _y; + private final int _width; + private final int _height; + + /// Левая граница + public int LeftBorder() + { + return _x; + }; + + /// Верхняя граница + public int TopBorder() + { + return _y; + } + + /// Правая граница + public int RightBorder() + { + return _x + _width; + } + + /// Нижняя граница + public int DownBorder() + { + return _y + _height; + } + + /// Середина объекта по горизонтали + public int ObjectMiddleHorizontal() + { + return _x + _width / 2; + } + + /// Середина объекта по вертикали + public int ObjectMiddleVertical() + { + return _y + _height / 2; + } + + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } +}