101
Sh
shapesaver / files
shapesaver / MyTriangle.java
1.1 KB
1/* 2sean caetano martin 3seancaetanomartin@gmail.com 4CIS 255 HY 5MyTriangle.java 6assignment#5 73/28/11 8*/ 9 10import java.awt.Color; 11import java.awt.Graphics; 12import java.awt.Polygon; 13import java.util.Random; 14 15public class MyTriangle extends MyLine 16{ 17 private Random randomNumbers = new Random(); 18 19 Color color; 20 private int x3; 21 private int y3; 22 23 public MyTriangle () 24 {super ();} 25 26 public MyTriangle (int x1, int y1, int x2, int y2, int x3, int y3, Color color) 27 { 28 super( x1, y1, x2, y2, color ); 29 setX3(x3); 30 setY3(y3); 31 } 32 33 public void setX3( int thirdX ) 34 { 35 x3 = ( thirdX < 0 ? 0 : thirdX-thirdX%50 ); 36 } 37 38 public int getX3() 39 { 40 return x3; 41 } 42 43 public void setY3( int thirdY ) 44 { 45 y3 = ( thirdY < 0 ? 0 : thirdY-thirdY%50 ); 46 } 47 48 public int getY3() 49 { 50 return y3; 51 } 52 53 @Override 54 public void draw (Graphics g) 55 { 56 g.setColor(getColor()); 57 58 int[] xValues = { getX1(), getX2(), getX3() }; 59 int[] yValues = { getY1(), getY2(), getY3() }; 60 g.fillPolygon(xValues,yValues, yValues.length ); 61 62 } 63}