Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Enhanced Lab 4.4 (4 lab points Start by downloading LabCh04Grid.java (in the Sketchpad folder) into a folder that contains Basic.java and Sketchpad.java. This class has

image text in transcribed
Enhanced Lab 4.4 (4 lab points Start by downloading LabCh04Grid.java (in the Sketchpad folder) into a folder that contains Basic.java and Sketchpad.java. This class has an instance variable number that can be interactively changed to any integer value between 5 and 50 (look at the keyPressed method to see this code and to figure out what keys to press to change number). Your job is to add code, including some loops, to the step method so that a grid of green lines will be drawn, with number grid points along the z and the y axes. For example, if number is 6, the sketchpad should look like this: Note that you want number+1 (7, in this example) ver tical lines and number+1 horizontal lines, and that they are spaced SIZEumber units apart. You should use for loops because the number of loop repetitions is known. Hint: to draw the vertical lines conveniently, use a double variable x that is set to 0 before the loop, is used in the body of the loop to give the a coordinate of the vertical line being drawn, and is then moved to the right a suitable amount at the end of the loop body. This is similar to how the index variable in a for loop works- in the example case, it goes from 0 to 6, inclusive, with the helpful variable a going along with it. Everywhere you change the value stored in the loop index variable, make a corresponding change to x. Use the same ideas to draw the horizontal lines. Enhanced Lab 4.4 (4 lab points Start by downloading LabCh04Grid.java (in the Sketchpad folder) into a folder that contains Basic.java and Sketchpad.java. This class has an instance variable number that can be interactively changed to any integer value between 5 and 50 (look at the keyPressed method to see this code and to figure out what keys to press to change number). Your job is to add code, including some loops, to the step method so that a grid of green lines will be drawn, with number grid points along the z and the y axes. For example, if number is 6, the sketchpad should look like this: Note that you want number+1 (7, in this example) ver tical lines and number+1 horizontal lines, and that they are spaced SIZEumber units apart. You should use for loops because the number of loop repetitions is known. Hint: to draw the vertical lines conveniently, use a double variable x that is set to 0 before the loop, is used in the body of the loop to give the a coordinate of the vertical line being drawn, and is then moved to the right a suitable amount at the end of the loop body. This is similar to how the index variable in a for loop works- in the example case, it goes from 0 to 6, inclusive, with the helpful variable a going along with it. Everywhere you change the value stored in the loop index variable, make a corresponding change to x. Use the same ideas to draw the horizontal lines

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

Step: 3

blur-text-image

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions