Assessment weight : 3% |
Due : Week 6 |
public double maximum( double x, double y, double z )
public double minimum( double x, double y, double z )
which take three numbers in the parameter list and return the maximum and minimum respectively.
import java.awt.*;
import java.applet.Applet;
public class ChinaFlag extends Applet {
public void paint( Graphics g ) {
int[] xArr = {43,78,85,96,130,102,113,88,61,70};
int[] yArr = {75,75,44,75,75,100,128,109,128,100};
int[] x1Arr = {168,176,180,181,189,180,180,175,168,171};
int[] y1Arr = {40,42,36,44,47,50,59,52,53,47};
int[] x2Arr = {194,202,208,206,213,204,202,199,191,196};
int[] y2Arr = {86,89,85,93,98,99,105,99,98,94};
int[] x3Arr = {182,188,192,195,204,196,198,193,186,188};
int[] y3Arr = {138,138,130,138,138,145,152,148,153,145};
int[] x4Arr = {143,151,156,157,165,155,157,152,144,148};
int[] y4Arr = {178,181,174,182,185,188,197,191,193,186};
g.setColor(Color.green);
g.fillRect(10, 15, 480, 335);
g.setColor(Color.red);
g.fillRect(15, 20, 467, 322);
g.setColor(Color.yellow);
g.fillPolygon(xArr,yArr,10);
g.fillPolygon(x1Arr,y1Arr,10);
g.fillPolygon(x2Arr,y2Arr,10);
g.fillPolygon(x3Arr,y3Arr,10);
g.fillPolygon(x4Arr,y4Arr,10);
}
}
Write an applet to read three number r, g, and b and create a new color using constructor method Color(int r,int g,int b) of Color class. Paint the flag using the new color as background color.