// Computer Science 121
// Example illustrating paint method

import java.awt.*;
import java.applet.Applet;

// Squares displays squares on the applet.
public class Squares extends Applet
{
     private Square greenSquare, redSquare;

     public void init ()
     {
          greenSquare = new Square (Color.green, 100, 100);
          redSquare = new Square (Color.red, 100, 200);
     } // method init

     public void paint (Graphics g)
     {
          greenSquare.drawSquare (g);
          redSquare.drawSquare (g);
     } // method paint
} // class Figures

class Square
{
     private Color color;
     private int x, y, side;

     Square (Color c, int xPosition, int yPosition)
     {
          color = c;
          x = xPosition;
          y = yPosition;
          side = 50;
     } // constructor

     public void drawSquare (Graphics g)
     {
          g.setColor (color);
          g.fillRect (x, y, side, side);
     } // method drawSquare
}// class Square