import java.awt.*; public class Wall extends PhysicsElement { public static final int SIDEWAYS=0; public static final int STRAIGHT=1; private static int id=0; protected Vector2D anchor; protected double length; protected final int orientation; private Wall() { // nobody can create a Wall without state super(id++); orientation=SIDEWAYS; } public Wall(Vector2D initPoint, int orient, double leng){ super(id++); anchor = initPoint; orientation = orient; length=leng; } public Vector2D getPosition() { return anchor; } public PhysicsElement collide(Ball b){ double b_x = b.getPosition().getX(); double b_y = b.getPosition().getY(); double r = b.getRadius(); if (orientation == STRAIGHT) if ((Math.abs(b_x-anchor.getX())< r) && // is touching wall? (anchor.getY()< b_y) && // is withing range? (b_y