Jack Green

Generation

generate functionSat, 16 Mar 2024

You are to complete 3 methods that all participate in drawing fancy rectangles: A fancy rectangle consists of three horizontal stripes that each contains a circle. The circles can be either filled or just outlined. Each stripe has its own height and colour. The diameter of each circle is 20% of the height of the stripe. For the top stripe, the circle is centered in the left-most third of the stripe. For the second stripe, the circle is centered in the middle third of the stripe. For the bottom stripe, the circle is centered in the right-most third of the stripe. The rectangle is 2/3 as high as it is wide (ratio 2:3) OR The width of the flag is 1.5 times the height of the flag. Below is an example of such rectangle where the circles are filled. right The vertical lines are not part of the rectangle. They just illustrate how all columns are the same width (one third of the total width of the rectangle). doFancyRect method so that: it asks for the height of each stripes, and whether the circles are filled or outlined, it then calls drawFancyRect with the necessary arguments. tip Note that we have written part of the code for you but it is not complete. drawFancyRect: it needs parameters, it must call drawStripe three times, it draws a black rectangle to outline the complete rectangle. drawStripe also needs parameters. It draws a stripe of the given width, height and colour with a circle at a given position.

ublic class Rectangle { public static void main(String[] args) { Rectangle r = new Rectangle(10, 10); System.out.println(r.getArea()); } private int width; private int height; public Rectangle(int width, int height) { this.width = width; this.height = height; } public int

Questions about programming?Chat with your personal AI assistant