import java.awt.*; public abstract class Shape2D { int x, y; boolean filled; Color color; public abstract void draw(Graphics g); public abstract void setSecondPoint(int a, int b); public Shape2D(int a, int b, Color c, boolean fill) { x = a; y = b; color = c; filled = fill; } } class rectangle extends Shape2D { private int width, height; public rectangle(int x, int y, Color c, boolean f) { super(x,y, c, f); width = 0; height = 0; } public void setSecondPoint(int a, int b) { width = a-x; height = b-y; } public void draw(Graphics g) { g.setColor(color); if (filled) g.fillRect(x, y, width, height); else g.drawRect(x, y, width, height); } } class circle extends Shape2D { private int radius; public circle(int x, int y, Color c, boolean f) { super(x,y, c, f); radius = 0; } public void setSecondPoint(int a, int b) { radius = (int)Math.sqrt((x-a)*(x-a) + (y-b)*(y-b)); } public void draw(Graphics g) { g.setColor(color); if (filled) g.fillOval(x, y, radius, radius); else g.drawOval(x, y, radius, radius); } } class line extends Shape2D { private int endx, endy; public line(int x, int y, Color c) { super(x,y, c, false); endx = 0; endy = 0; } public void setSecondPoint(int a, int b) { endx = a; endy = b; } public void draw(Graphics g) { g.setColor(color); g.drawLine(x, y, endx, endy); } } class text extends Shape2D { private String text; public text(int a, int b, Color c, String s) { super(a, b, c, false); text = s; } public void setSecondPoint(int a, int b) {} public void draw(Graphics g) { g.setColor(color); g.drawString(text, x, y); } }