Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. // Lab06vst.java
  2. // Student Version
  3.  
  4. import java.awt.*;
  5. import java.applet.*;
  6. import java.util.*;
  7.  
  8.  
  9. public class Labb06vst extends Applet
  10. {
  11.  
  12. public void paint(Graphics g)
  13. {
  14. // Draw Grid
  15. g.drawRect(10,10,780,580);
  16. g.drawLine(400,10,400,590);
  17. g.drawLine(10,300,790,300);
  18.  
  19.  
  20.  
  21. // Draw Random Lines
  22.  
  23.  
  24. for (int k = 1; k <=100; k++)
  25. {
  26. int x1 = (int) (Math.random() * 400);
  27. int y1 = (int) (Math.random() * 300);
  28. int x2 = (int) (Math.random() * 400);
  29. int y2 = (int) (Math.random() * 300);
  30. g.drawLine(x1, y1, x2, y2);
  31. int red = (int) (Math.random() * 256);
  32. int green = (int) (Math.random() * 256);
  33. int blue = (int) (Math.random() * 256);
  34. g.setColor(new Color(red,green,blue));
  35. }
  36.  
  37.  
  38. // Draw Random Squares
  39. for (int k = 1; k<=100; k++)
  40. {
  41. int x1 =((int) (Math.random() * 350) + 400);
  42. int y1 =((int) (Math.random() * 260));
  43. int red = (int) (Math.random() * 256);
  44. int green = (int) (Math.random() * 256);
  45. int blue = (int) (Math.random() * 256);
  46. g.setColor(new Color(red,green,blue));
  47. g.fillRect(x1,y1,50,50);
  48. }
  49.  
  50. // Draw Random Circles
  51. for (int k= 1; k<=100; k++)
  52. {
  53.  
  54. int red = (int) (Math.random() * 256);
  55. int green = (int) (Math.random() * 256);
  56. int blue = (int) (Math.random() * 256);
  57. g.setColor(new Color(red,green,blue));
  58. }
  59.  
  60.  
  61. // Draw 3-D Box
  62. Polygon cube = new Polygon();
  63. cube.addPoint(350,500);
  64. cube.addPoint(450,500);
  65. cube.addPoint(350,600);
  66. g.drawPolygon(cube);
  67.  
  68.  
  69.  
  70.  
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement