can someone help me create this. this is my code so far import java.awt.Color; i
ID: 3825096 • Letter: C
Question
can someone help me create this. this is my code so far
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JApplet;
public class OCCLogo extends JApplet{
public void init()
{
setSize(550,450);
}
public void paint(Graphics canvas)
{
//lets define a for loop to print 5 circles going across
for(int row = 0; row <= 840; row += 210)
{
//lets define a nested for loop to print 4 circles going down
for(int col = 0; col <= 690; col +=230)
{
// orange
canvas.setColor(Color.ORANGE);
canvas.fillOval(row, col, 200, 200);
//white
canvas.setColor(Color.WHITE);
canvas.fillOval(row +10, col + 10, 180, 180);
//blue
canvas.setColor(Color.BLUE);
canvas.fillArc(row + 15, col + 15, 170, 170, 60, 265);
// white
canvas.setColor(Color.WHITE);
canvas.fillOval(row + 40, col + 30, 145, 145);
//blue
canvas.setColor(Color.BLUE);
canvas.fillArc(row + 45, col +35, 135, 135, 70, 250);
// white
canvas.setColor(Color.WHITE);
canvas.fillOval(row + 60, col + 50, 115, 115);
// message
canvas.setColor(Color.BLUE);
canvas.drawString("Orange Coast College", row + 35, col + 220);
}
}
}
}
Explanation / Answer
Instead of setting colors manually , create one color array and then fill each oval in the loop like this:
Color[] c = { Color.BLUE, Color.WHITE, Color.ORANGE };
for(int i=0; i<8; ++i){
g.setColor(c[i]);
g.fillArc(x, y, w, h, i*factor1, factor2);
}
//Adjust the factors Accordingly.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.