import java.awt.Graphics; import java.awt.Color; /**Creates a stationary object "Wall," which is a polygon, and implements interface Polygon.*/ public class Wall extends StationaryObject implements Polygon { private int numberOfPoints; /**The coordinates of the polygon are defined by an array of x coordinate values (all the x coordinates of the points of the polygon) * and an array of y coordinate values (all the y coordinates of the points of the polygon)*/ private int[] xPolygon = new int[numberOfPoints]; private int[] yPolygon = new int[numberOfPoints]; /**initializes Wall as a rectangle with all coordinates at (0,0)*/ public Wall() { super(); int[] x = {0, 0, 0, 0}; int[] y = {0, 0, 0, 0}; numberOfPoints = 4; setCoordinates(x, y, x.length); } /**Creates a polygonal wall. * @param name s, color c * @param newXPolygon an array of x values * @param newYPolygon an array of y values*/ public Wall (String s, Color c, int[] newXPolygon, int[] newYPolygon, int newNumberOfPoints) { super(s, c); numberOfPoints = newNumberOfPoints; xPolygon = newXPolygon; yPolygon = newYPolygon; } public void setCoordinates(int[] x, int[] y, int n) { xPolygon = x; yPolygon = y; numberOfPoints = n;//should be x.length } public int[] getXCoordinates() { return xPolygon; } public int[] getYCoordinates() { return yPolygon; } /**Draws the wall onto Graphics object canvas*/ public void draw(Graphics canvas) { canvas.setColor(super.getColor()); canvas.drawPolygon(xPolygon, yPolygon, numberOfPoints); } }