import java.awt.Color; /**Parent class for all moveable objects. It inherits the properties of BoxedBallsObject. * All moveable objects have a mass and a velocity*/ public class MoveableObject extends BoxedBallsObject { private double mass; private double xVelocity, yVelocity; private MyMathOperations newOperation; public MoveableObject() { super(); mass = 0.0; xVelocity = 0.0; yVelocity = 0.0; newOperation = new MyMathOperations(); } /**creates a moveable object * @param s name of class type string * @param c color of class type color * @param m mass of primitive type double * @param v velocity of primitive type double*/ public MoveableObject(String s, Color c, double m, double vx, double vy) { super(s, c); mass = m; xVelocity = vx; yVelocity = vy; } public void setVelocity(double newXVelocity, double newYVelocity) { if (mass == 1.0 / 0.0) { xVelocity = 0; yVelocity = 0; } else { xVelocity = (newXVelocity); yVelocity = (newYVelocity); } } public void setMass(double newMass) { mass = newMass; } public double getXVelocity() { return xVelocity; } public double getYVelocity() { return yVelocity; } public double getMass() { return mass; } /**method getColor() overwrides getColor in BoxedBallsObject. It will be overwridden again in Ball * so that the color can be used as input for method draw().*/ public Color getColor() { return super.getColor(); } }