The code below is designed so that ONLY one shape will be displayed (assume the rest of the program has been developed):
if (magicShape == 0) {
// magicShape is 0, draw and color a rectangle
Rectangle2D.Float shape = new Rectangle2D.Float(x, y, w1, h1);
dk.fill(shape);
} else if (magicShape == 1) {
// magicShape is 1, draw and color an ellipse
Ellipse2D.Float shape1 = new Ellipse2D.Float(x, y, w1, h1);
dk.fill(shape1);
} else if (magicShape == 2) {
// magicShape is 2, draw and color a circle
Ellipse2D.Float shape2 = new Ellipse2D.Float(x, y, w2, h2);
dk.fill(shape2);
} else {
// magicShape is 3, draw a square
Rectangle2D.Float shape3 = new Rectangle2D.Float(x, y, w2, h2);
dk.draw(shape3);
}
Selecciona uno de los siguientes: