Please Read Carefully I already completed Part I and the lin

Please Read Carefully:

I already completed Part I and the links that Part II ask for are below.

Part II: Use the Graphics, Color and Font objects to construct a picture with shapes of your design. You will be graded by the design, color, and documentation. You design must include the followings:

1. at least 3 different basic shapes

2. at least 2 different none-basic colors which including one that uses Random number to generate color components. Indicate which shape has random color in your opening program description.

3. your full name must shown in the output screen

4. the complexity of your design should be compatible to the attached sample files.

5. The program indentation must be correct.

6. The filename need be include your firstInitialLastName in it.

The file name should reflect to your drawing too. You can draw your shapes in a regular JPanel or you can draw them in an applet. Use the sample programs attached- Fishtank.java and Fishtank.htm for JApplet graphics and Tutle.java for the stand along window graphics. In order to draw shapes in an applet, you need construct two files: a java program which draw the picture of your design and a .html file which invokes the java class of your design. The you need compile the java program and view the html file using : a:\\appletviewer xxx.html A good design with effort is expected from each of you in order to get a full marks for this assignment

Solution

import java.awt.*;
import java.util.*;
import java.applet.*;

//The basic applet class.The applet shows 4 cars crossing each other at a square.

public class Animation extends Applet implements Runnable
{
Thread t;
//4 variables denotes the car\'s positions.
int x1=0,x2=380,y1=50,y2=250;
public void start()
{
if(t==null)
{
t=new Thread(this,\"New Thread\");
//New side Thread created on start of applet.
t.start();
}
}
public void stop()
{
if(t!=null)
{
t=null;
//On stop of applet the created thread is destroyed.
}
}

//Implementation of method run() of Runnable interface.
public void run()
{
Thread t1=Thread.currentThread();
while(t==t1)
{
repaint();
try
{
Thread.sleep(100);
}
catch(Exception e)
{ }
}
}

public void paint(Graphics g)
{
setBackground(Color.cyan);
g.setColor(Color.BLACK);
x1=(x1+16)%400;
x2=x2-16;
y1=(y1+12)%300;
y2=y2-12;
if(y2<0)
y2=288;
if(x2<0)
x2=384;
//roads using 2 filled rectangles using black color.
g.fillRect(0,130,400,40);
g.fillRect(180,0,40,305);
//the white colored lines.
g.setColor(Color.white);
for(int i=0;i<20;i++)
{
if(i!=9 && i!=10)
g.drawLine(i*20,150,i*20+10,150);
}
for(int j=0;j<15;j++)
{
if(j!=7 && j!=8)
g.drawLine(200,j*20,200,j*20+10);
}
//4 different colored cars using filled round rectangles.
g.setColor(Color.red);
g.fillRoundRect(x2,152,20,8,2,2);
g.setColor(Color.yellow);
g.fillRoundRect(x1,140,20,8,2,2);
g.setColor(Color.green);
g.fillRoundRect(190,y1,8,20,2,2);
g.setColor(Color.blue);
g.fillRoundRect(202,y2,8,20,2,2);
}
}

Please Read Carefully: I already completed Part I and the links that Part II ask for are below. Part II: Use the Graphics, Color and Font objects to construct a
Please Read Carefully: I already completed Part I and the links that Part II ask for are below. Part II: Use the Graphics, Color and Font objects to construct a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site