From 03d8081a7382705a81ed2c80e2bc1e4f807b5dc6 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sun, 11 Aug 2019 17:52:15 -0600 Subject: add documentation --- src/Q9/Robot.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/Q9/Robot.java') 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 = ""; -- cgit v1.2.3