/**
See instructions to complete this code.
*/
import java.applet.Applet;
import java.awt.*;
public class Assignment2 extends Applet{
public void paint(Graphics g){
int w = getSize().width;
int h = getSize().height;
int centerx = 100;
int centery = h/2+100;
int horizontal_space = 150;
int vertical_space = 150;
g.drawLine(w/2,0, w/2,h);
g.drawLine(0,h/2, w,h/2);
Font f = new Font("TimesRoman", Font.PLAIN, 8);
Font f2 = new Font("TimesRoman", Font.PLAIN, 10);
Font f3 = new Font("TimesRoman", Font.PLAIN, 12);
/*
g.setFont(f3);
Type here your code for the first question.
*/
/*
g.setFont(f2);
Type here your code for the second question.
*/
/*
This is the black square.
*/
g.fillRect(w/2+50, 50, horizontal_space, vertical_space);
/*
Every planet will have a diameter = 10;
*/
g.setFont(f);
g.setColor(Color.yellow);
g.fillOval(centerx,centery, 20,20); //This is the sun
g.setColor(Color.black);
g.drawString("Sun", centerx, centery);
g.drawOval(centerx- 20, centery -20, 60, 60); //First Orbit
g.drawOval(centerx- 40, centery -40, 100,100);//Second Orbit
/*Type here your code for the Third Orbit*/
g.setColor(Color.pink);
g.fillOval(centerx-20-10/2, centery-20+60/2-10/2, 10, 10);//This is Mercury
g.setColor(Color.black);
g.drawString("Mercury", centerx-20-10/2, centery-20+60/2-10/2);
g.setColor(Color.red);
g.fillOval(centerx+5, centery+60-5, 10, 10);//This is Venus
g.setColor(Color.black);
g.drawString("Venus", centerx+5, centery+60-5);
/*
Type here your code for the Earth, Moon's orbit, and Moon.
*/
}
}