/** * */ // the idea of the last line, for g.fillPolygon(xValues, yValues, 31) "31 points'" could be useful package onetomany.etc; import java.awt.Color; import java.awt.Graphics; import java.awt.Point; //import javax.swing.*; //import java.awt.*; /** * @author Faria Nassiri-Mofakham * */ public abstract class Shape { /** * */ protected Point location; protected int dimension; protected Color color; public Color getColor() { return color; } public void setColor(Color color) { this.color = color; } public int getDimension() { return dimension; } public void setDimensions(int dim) { this.dimension = dim; } public Shape(Point loc, int dim, Color col) { setLocation(loc); setDimensions(dim); setColor(col); } public Point getLocation() { return location; } public void setLocation(Point loc) { this.location = loc; } public void paint(Graphics g, Color c) { g.setColor(c); draw(g); } public void draw(Graphics g) { int xLocation = this.getLocation().x; int yLocation = this.getLocation().y; int[] xValues = {xLocation, xLocation, xLocation+getDimension()}; int[] yValues = {yLocation, yLocation, yLocation+getDimension()}; g.fillPolygon(xValues, yValues, 31); //31 points } }