// Computer Science 121
// Example of arrays of points that make up a triangle

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

public class Triangles extends Applet
{
     private Triangle triangle;
 
     public void paint (Graphics g)
     {
          for (int count = 0; count < 5; count ++)
          {
               int [] xList = {100-count*10, 150, 200+count*10};
               int [] yList = {100+count*30, 100, 100+count*30};
               triangle = new Triangle (Color.green, xList, yList);
               triangle.drawTriangle (g);
          }
     } // method paint
} // class Triangles
 
class Triangle
{
     private Color color;
     private int [] xList, yList;
     private Polygon poly;
 
     Triangle (Color c, int [] x, int [] y)
     {
          color = c;
          xList = x;
          yList = y;
     } // constructor
 
      public void drawTriangle (Graphics g)
      {
           poly = new Polygon (xList, yList, 3);
           g.setColor (color);
           g.fillPolygon (poly);
      } // method drawTriangle
} // class Triangle