This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Java Shape

By: a guest on Mar 7th, 2012  |  syntax: None  |  size: 1.28 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.*;
  2.  
  3. /**
  4.  * Write a description of class Heptagon here.
  5.  *
  6.  * @author (your name)
  7.  * @version (a version number or a date)
  8.  */
  9. public class Heptagon extends SuperClass
  10. {
  11.     // instance variables - replace the example below with your own
  12.     private int height;
  13.     private int width;
  14.  
  15.     /**
  16.      * Constructor for objects of class Heptagon
  17.      */
  18.     public Heptagon()
  19.     {
  20.         xPosition = 50;
  21.         yPosition = 15;
  22.         height = 30;
  23.         width = 50;
  24.         color = "red";
  25.         isVisible = false;
  26.     }
  27.  
  28.     /**
  29.      * An example of a method - replace this comment with your own
  30.      *
  31.      * @param  y   a sample parameter for a method
  32.      * @return     the sum of x and y
  33.      */
  34.    public void draw()
  35.     {
  36.         super.draw();
  37.         if(super.isVisible) {
  38.             Canvas canvas = Canvas.getCanvas();
  39.             int[] xpoints = {xPosition + (width/2),xPosition, xPosition + width, xPosition, xPosition + width, xPosition + (width/2) };
  40.             int[] ypoints = {yPosition, yPosition - (height/4), yPosition -  (height/4), yPosition - (height/2),yPosition- (height/2), yPosition - height };
  41.             canvas.draw(this, color, new Polygon(xpoints, ypoints, 6));
  42.             canvas.wait(10);
  43.         }
  44.     }
  45. }
clone this paste RAW Paste Data