Guest User

Java Shape

a guest
Mar 7th, 2012
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×