Commit 61064f95 authored by Elena Berrios's avatar Elena Berrios
Browse files

Circle class documentation

parent 99141277
Loading
Loading
Loading
Loading
+24 −13
Original line number Diff line number Diff line
@@ -5,13 +5,22 @@ import android.graphics.Canvas;
import android.graphics.Paint;

/**
 * Circle is an abstract class which implements GameObject's abstract
 * draw method to draw the object as a circle.
 * Circle is an abstract class that extends GameObject. It provides functionality to
 * check the radius of the circle, check for collisions with other Circle objects, and
 * draw the circle to the screen. The Player and Detector classes both extend Circle.
 */
public abstract class Circle extends GameObject{
    protected double radius;
    protected Paint paint;

    /** Constructs a circle that can be drawn to the screen.
     * @param context the current context
     * @param color the color of the drawn circle, defined in the res/values/colors.xml file
     * @param positionX an x-coordinate for the center of the circle
     * @param positionY a y-coordinate for the center of the circle
     * @param radius the radius (in pixels) of the circle
     * @return the newly constructed Circle object
     */
    public Circle(Context context, int color, float positionX, float positionY, double radius) {
        super(positionX, positionY);
        this.radius = radius;
@@ -22,10 +31,10 @@ public abstract class Circle extends GameObject{
    }

    /**
     * isColliding checks if two circle objects are colliding based on position and radii
     * @param obj1
     * @param obj2
     * @return
     * Checks if two Circle objects are colliding based on position and radii.
     * @param obj1 the first Circle object
     * @param obj2 the second Circle object
     * @return true if the objects are colliding and false if not
     */
    public static boolean isColliding(Circle obj1, Circle obj2) {
        double distance = getDistanceBetweenObjects(obj1, obj2);
@@ -37,16 +46,18 @@ public abstract class Circle extends GameObject{
        }
    }

    /**
     * Gets the radius of the circle.
     * @return the radius of the circle
     */
    private double getRadius() {
        return radius;
    }

    public abstract void draw(Canvas canvas);
    /*
    public void draw(Canvas canvas) {
        // draw player circle (cast doubles to floats as required)
        canvas.drawCircle((float) positionX, (float) positionY, (float) radius, paint);
    }
    /**
     * Abstract function to draw Circle objects to the screen.
     * See Player and Detecter classes for implementations.
     * @param canvas the canvas to which the object will be drawn
     */

    public abstract void draw(Canvas canvas);
}