Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exception in thread main java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at Art.main(Art.java:29) What does this mean/How do I fix this? 1 public

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at Art.main(Art.java:29)

What does this mean/How do I fix this?

1 public class Art { 2 // plot a square, centered on (x, y) of the given side length 3 // with a light gray background and black border 4 public static void drawSquare(double x, double y, double size) { 5 PennDraw.setPenColor(PennDraw.LIGHT_GRAY); 6 PennDraw.filledSquare(x, y, size/2); 7 PennDraw.setPenColor(PennDraw.BLACK); 8 PennDraw.square(x, y, size/2); 9 } 10 // plot an order n recursive squares pattern 11 // centered on (x, y) of the given side length 12 public static void draw(int n, double x, double y, double size) { 13 if (n == 0) return; 14 15 drawSquare(x, y, size); 16 17 // 2.2 ratio looks good 18 double ratio = 2.2; 19 20 // recursively draw 4 smaller trees of order n-1 21 draw(n-1, x - size/2, y - size/2, size/ratio); // lower left 22 draw(n-1, x - size/2, y + size/2, size/ratio); // upper left 23 draw(n-1, x + size/2, y - size/2, size/ratio); // lower right 24 draw(n-1, x + size/2, y + size/2, size/ratio); // upper right 25 } 26 // read in an integer command-line argument n and plot an order n recursive 27 // squares pattern 28 public static void main(String[] args) { 29 int n = Integer.parseInt(args[0]); 30 double x = 0.5, y = 0.5; // center of square 31 double size = 0.5; // side length of square 32 draw(n, x, y, size); 33 } 34 35 36 } 37

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago