this question is about a java applet modification
Posted on 2004-10-06
in this program my teacher asked me to add some new features to this program by modifying the source code , he asked like ten things which i know and i've already modify but the two things i dont get are this :
i need to add more ovals to this program at less 5 more
i need to change the color of the ovals by maintaining the gredient effect of the original applet ( this question an expert answered for me thanks)
this is the code :
public class Wormhole extends Applet
* Do all the drawing.
public void paint(Graphics g)
// Draw the black background.
g.fillRect(0, 0, 500, 350);
// Draw ten nested "holes."
// Draw the text, in white with a blue drop shadow.
g.setFont(new Font("TimesRoman", Font.BOLD, 36));
g.drawString("On to Cydonia!", 22, 300);
g.drawString("On to Cydonia!", 20, 298);
* Using the supplied Graphics object, draw the n-th hole.
* n should be between 0 (darkest, largest) and 9 (lightest,
private void drawHole(int n, Graphics g)
int X0 = 50, // x-anchor
Y0 = 50, // y-anchor
W0 = 350, // initial width
H0 = 200, // initial height
X_INC = 30, // x-anchor increment
Y_INC = 10, // y-anchor increment
RG_INC = 10, // red-green increment
BLUE_INC = 25; // blue increment
g.setColor(new Color(n * RG_INC, n * RG_INC, (n + 1) * BLUE_INC));
g.fillOval(X0 + n * X_INC, Y0 + n * Y_INC,
W0 - n * X_INC, H0 - n * 2 * Y_INC);
ok my teacher told me to add more lines like this one (drawHole(10, g);) and then do the multiplications (ohh boy multiplication ??????) this is the part i dont get how you multiply this can you tell me step by step cause my assignment works great but to be honest i just guess the numbers and i dont know how to do it , please tell me what should i multiply depending on the ovals you will add to the applet , thanks in advance