Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. // APCS1 Lab Test 2
  2. //
  3. // Prog09.java
  4. //
  5. // Box missing front & back
  6. //
  7. // Points: 4
  8. //
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. // Write a program that will draw a 3-D box without the front or back.
  12. // The remaining 4 sides need to be drawn as Polygon objects.
  13. // The colors of these 4 sides need to be red, green, blue and yellow.
  14. // It does not matter which side gets which of the 4 colors.
  15. //
  16. ////////////////////////////////////////////////////////////////////////////////
  17. // NOTE: You will need to load Prog09.html in order to execute this file.
  18. //
  19. // ALSO: The sample exection of this file is on the back of your lab test sheet.
  20.  
  21.  
  22.  
  23. import java.awt.*;
  24. import java.applet.*;
  25. import java.util.*;
  26.  
  27.  
  28. public class Prog09 extends Applet
  29. {
  30.  
  31. public void paint(Graphics g)
  32. {
  33. Polygon top = new Polygon();
  34. top.addPoint(100, 100);
  35. top.addPoint(200, 100);
  36. top.addPoint(250, 150);
  37. top.addPoint(150, 150);
  38. g.setColor(Color.blue);
  39. g.fillPolygon(top);
  40.  
  41. Polygon left = new Polygon();
  42. left.addPoint(100, 100);
  43. left.addPoint(150, 150);
  44. left.addPoint(150, 250);
  45. left.addPoint(100, 200);
  46. g.setColor(Color.red);
  47. g.fillPolygon(left);
  48. Polygon bottom = new Polygon();
  49. bottom.addPoint(150, 250);
  50. bottom.addPoint(150, 200);
  51. bottom.addPoint(200, 200);
  52. bottom.addPoint(250, 250);
  53. g.setColor(Color.yellow);
  54. g.fillPolygon(bottom);
  55.  
  56. Polygon right = new Polygon();
  57. right.addPoint(200, 150);
  58. right.addPoint(250, 150);
  59. right.addPoint(250, 250);
  60. right.addPoint(200, 200);
  61. g.setColor(Color.green);
  62. g.fillPolygon(right);
  63.  
  64.  
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement