Professional Documents
Culture Documents
Lab 4
Lab 4
*; public class randomLine extends JFrame { public randomLine() { super("Random Line - Lab Assignment 4"); setSize(500,500); this.setVisible(true); } public void paint(Graphics g) { for(int i=0;i<400;i+=2) { int x=(int)(Math.random()*600); int x1=(int)(Math.random()*600); int i2=(int)(Math.random()*600); g.setColor(new Color((float)Math.random(),(float)Math.random(), (float)Math.random())); g.drawLine(x, x1, i, i2); } } public static void main(String args[]) { randomLine rL=new randomLine(); } }
Output
import javax.swing.*; import java.awt.event.*; public class randomLine extends JFrame { public randomLine() { super("Random Ellipse - Lab Assignment 4"); setSize(500,500); this.setVisible(true); } public void paint(Graphics g) { for(int i=0;i<35;i++) { int x=(int)(Math.random()*300); int y=(int)(Math.random()*300); int w=(int)(Math.random()*300); //width size int h=(int)(Math.random()*200); //height size g.setColor(new Color((float)Math.random(),(float)Math.random(), (float)Math.random())); g.drawOval(x,y,w,h); } } public static void main(String args[]) { randomLine rL=new randomLine(); } }
Output
CSC 533
(MULTIMEDIA PROGRAMMING) LAB ASSIGNMENT 4