
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Computer Programming I; Subject: Computer Science; University: Pace University-New York; Term: Fall 1999;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Computer Science 121 Assignment 3 Due: October 11, 1999 Create a Java applet that will draw three circles similar to those on a traffic light. Their colors should be red, yellow (orange actually looks better) and green. Position them on the applet in the order that they would be for a traffic light. Run the applet from an html file like the one below.
Lights
Lights
Your applet should have the following form: // An applet with a class that draws a few circles that look like a traffic light. import java.awt.*; import java.applet.Applet; public class Lights extends Applet { private circle redCircle, yellowCircle, greenCircle; public void init () { redCircle = new circle (); yellowCircle = new circle (); greenCircle = new circle (); } // method init public void paint (Graphics g) { // Fill in the statements here that would draw the circles. } // method paint } // class shapes // A class that defines a circle. class circle { public void displayCircle (Graphics g, Color c, int xPos, int yPos, int diameter) { // Fill in the statements here that would set the color and draw the circle. } // method displayCircle } // class circle