-
Which class is the main class?
__________________________________________
-
How many lines does the progrm draw? _________
-
Where is the first line drawn? _________________________________________
-
How many ovals does the program draw? _______
-
Where is the first oval drawn? _________________________________________
-
What happens when you click the mouse?
_________________________________________
import java.awt.*;
public class Limb {
int x,y, x2, y2;
Limb(int startx, int starty,
int endx, int endy) {
x = startx;
y = starty;
x2 = endx;
y2 = endy;
}
public void paint(Graphics
g) {
g.drawLine(x,y,x2, y2);
g.drawOval(x2-2, y2-2, 4, 4);
}
}
|
public class Scene extends java.applet.Applet
{
Person f1, f2;
public void Scene()
{
f1 = new Person(10, 20);
f2 = new Person(100,200);
}
public void paint(Graphics
g)
{
f1.paint(g);
f2.paint(g);
}
}
public class Person {
int x,y;
Limb leftarm;
Person(int startx, int starty)
{
x = startx;
y = starty;
leftarm = new Limb(x, y+5, x-5, y+5);
}
public void paint(Graphics
g) {
leftarm.paint(g);
return true;
}
} |