Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

No1 /** * * @author Ekin*/ import javax.swing.*; import java.awt.*; import java.awt.event.

*; 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

No2 import java.awt.*;

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

NAME ID GROUP LECTURER

NURASYIKIN BINTI MAT ZIN 2011507255 CS2334B MADAM NURUL HAZRA

You might also like