import java.awt.*; // //*Class Square creates objects that can draw a square on the graphical surfaca // @author Irena pevac // @version march 18, 2002 public class Square { // instance variables private int left; private int top; private int size; private int number; private String name; /** * Constructor for objects of class Square */ public Square(int l, int t, int s,int n, String str) { // initialise instance variables left=l; top=t; size=s; number =n; name=str; } // A method to draw a square on graphical surface g // Squares are color coded. // Objects with an even number draw red square and // those with an odd number draw yellow squares. public void drawSquare(Graphics g) { if (number%2==0) g.setColor(Color.yellow); else g.setColor(Color.red); g.fillRect(left,top,size,size); g.setColor(Color.black); g.drawRect(left,top,size,size); g.drawString(name,left+15,top+35); } }