summaryrefslogtreecommitdiff
path: root/src/Q9/Robot.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Q9/Robot.java')
-rw-r--r--src/Q9/Robot.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Q9/Robot.java b/src/Q9/Robot.java
index 62a972d..787f7cc 100644
--- a/src/Q9/Robot.java
+++ b/src/Q9/Robot.java
@@ -1,3 +1,11 @@
+/**
+ * Assignment 2, COMP268 Class: Robot.java
+ *
+ * @description A class used to represent the location of a robot on a grid.
+ * @author: mo khan Student ID: 3431709
+ * @date August 5, 2019
+ * @version 1.0
+ */
package Q9;
public class Robot {
@@ -27,31 +35,56 @@ public class Robot {
private int x;
private int y;
+ /**
+ * Constructs an instance of a robot.
+ * @param x the x coordinate of the robot.
+ * @param y the y coordinate of the robot.
+ */
public Robot(int x, int y) {
this.x = x;
this.y = y;
}
+ /**
+ * @return the x coordinate
+ */
public int getX() {
return x;
}
+ /**
+ * @return the y coordinate
+ */
public int getY() {
return y;
}
+ /**
+ * @param x the x coordinate to move to.
+ */
public void setX(int x) {
this.x = x;
}
+ /**
+ * @param y the y coordinate to move to.
+ */
public void setY(int y) {
this.y = y;
}
+ /**
+ * @return true if the robot is at the given coordinate
+ */
public boolean atPosition(int x, int y) {
return getX() == x && getY() == y;
}
+ /**
+ * @param r1 robot one.
+ * @param r2 robot two.
+ * @return the grid with each of the robots printed.
+ */
public static String printGrid(Robot r1, Robot r2) {
String grid = "";