Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lab06vst.java
- // Student Version
- import java.awt.*;
- import java.applet.*;
- import java.util.*;
- public class Labb06vst extends Applet
- {
- public void paint(Graphics g)
- {
- // Draw Grid
- g.drawRect(10,10,780,580);
- g.drawLine(400,10,400,590);
- g.drawLine(10,300,790,300);
- // Draw Random Lines
- for (int k = 1; k <=100; k++)
- {
- int x1 = (int) (Math.random() * 400);
- int y1 = (int) (Math.random() * 300);
- int x2 = (int) (Math.random() * 400);
- int y2 = (int) (Math.random() * 300);
- g.drawLine(x1, y1, x2, y2);
- int red = (int) (Math.random() * 256);
- int green = (int) (Math.random() * 256);
- int blue = (int) (Math.random() * 256);
- g.setColor(new Color(red,green,blue));
- }
- // Draw Random Squares
- for (int k = 1; k<=100; k++)
- {
- int x1 =((int) (Math.random() * 350) + 400);
- int y1 =((int) (Math.random() * 260));
- int red = (int) (Math.random() * 256);
- int green = (int) (Math.random() * 256);
- int blue = (int) (Math.random() * 256);
- g.setColor(new Color(red,green,blue));
- g.fillRect(x1,y1,50,50);
- }
- // Draw Random Circles
- for (int k= 1; k<=100; k++)
- {
- int red = (int) (Math.random() * 256);
- int green = (int) (Math.random() * 256);
- int blue = (int) (Math.random() * 256);
- g.setColor(new Color(red,green,blue));
- }
- // Draw 3-D Box
- Polygon cube = new Polygon();
- cube.addPoint(350,500);
- cube.addPoint(450,500);
- cube.addPoint(350,600);
- g.drawPolygon(cube);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement