Use Java Draw two identical Cars at two different locations. You will do this by using relative positioning instead of absolute positioning, that is, you must position the components of your Car relative to a base location 1. Say you wanted to put the Car at the position (100, 100). What would the code look like in Java? 2. How can we abstract the code you wrote for question one such that we can plug in any (x, y) coordinate and create your Car relative to that position? 3. Would it be advantageous for us to create methods to draw each of the individual components of the Car and then write another method that calls each of these methods in succession? Why or why not? 4. Write out a chunk of your method (about 5 lines of the body plus the header), and diagram these parts For the implementation, you will write a method to draw your Car based on coordinates passed to it. To help you, keep the following in mind:1. There are four variables given in P2Start.java: (x1, y1) is the location of the first pad, and (x2, y2) is the location of the second pad. 2. Draw the components of your Car relative to these coordinates. For example, suppose the first pad is at (100, 200) and you want to place a leg at location (110, 230) so that it will appear 10 to the right and 30 down on the pad. Locate it at (x1 + 10, y1 + 30). In other words, every coordinate that you use to place the components of your Car must involve x1 and y1 (or x2 and y2). Your Car must contain at least 6 parts
Use Java
Draw two identical Cars at two different locations. You will do this by using relative positioning instead of absolute positioning, that is, you must position the components of your Car relative to a base location
1. Say you wanted to put the Car at the position (100, 100). What would the code look like in Java?
2. How can we abstract the code you wrote for question one such that we can plug in any (x, y) coordinate and create your Car relative to that position?
3. Would it be advantageous for us to create methods to draw each of the individual components of the Car and then write another method that calls each of these methods in succession? Why or why not?
4. Write out a chunk of your method (about 5 lines of the body plus the header), and diagram these parts
For the implementation, you will write a method to draw your Car based on coordinates passed to it. To help you, keep the following in mind:1. There are four variables given in P2Start.java: (x1, y1) is the location of the first pad, and (x2, y2) is the location of the second pad.
2. Draw the components of your Car relative to these coordinates. For example, suppose the first pad is at (100, 200) and you want to place a leg at location (110, 230) so that it will appear 10 to the right and 30 down on the pad. Locate it at (x1 + 10, y1 + 30). In other words, every coordinate that you use to place the components of your Car must involve x1 and y1 (or x2 and y2).
Your Car must contain at least 6 parts
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 1 images