8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. - Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: D Output - 1213 Module2 (run) X run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt. Rectangle [x=0, y=0,width=100,height=50] box1: java.awt. Rectangle [x=20, y=20,width=40,height=30] box2: java.awt. Rectangle [x=0, y=0,width=50, height=30] Area of intersecting rectangle: 300.0 box3: java.awt. Rectangle [x=20, y=20,width=30,height=10] BUILD SUCCESSFUL (total time: 2 seconds) 88083 D D
8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. - Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: D Output - 1213 Module2 (run) X run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt. Rectangle [x=0, y=0,width=100,height=50] box1: java.awt. Rectangle [x=20, y=20,width=40,height=30] box2: java.awt. Rectangle [x=0, y=0,width=50, height=30] Area of intersecting rectangle: 300.0 box3: java.awt. Rectangle [x=20, y=20,width=30,height=10] BUILD SUCCESSFUL (total time: 2 seconds) 88083 D D
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![8) Now use the Rectangle class to complete the following tasks:
-
Create another object of the Rectangle class named box2 with a width of 100
and height of 50. Note that we are not specifying the x and y position for this
Rectangle object. Hint: look at the different constructors)
Display the properties of box2 (same as step 7 above).
-
Call the proper method to move box1 to a new location with x of 20, and y of 20.
Call the proper method to change box2's dimension to have a width of 50 and a
height of 30.
Display the properties of box1 and box2.
-
Call the proper method to find the smallest intersection of box1 and box2 and
store it in reference variable box3.
-
Calculate and display the area of box3. Hint: call proper methods to get the
values of width and height of box3 before calculating the area.
Display the properties of box3.
9) Sample output of the program is as follow:
Output - 1213 Module2 (run) x
run:
box1: java.awt. Rectangle [x=10, y=10,width=40,height=30]
box2: java.awt. Rectangle [x=0, y=0,width=100,height=50]
box1: java.awt. Rectangle [x=20, y=20,width=40,height=30]
box2: java.awt. Rectangle [x=0, y=0,width=50,height=30]
Area of intersecting rectangle: 300.0
box3: java.awt.Rectangle [x=20, y=20,width=30,height=10]
BUILD SUCCESSFUL (total time: 2 seconds)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6a70e2d2-d641-435a-b212-d4266cff05fc%2Fe300693a-a1f5-4cd2-8ec7-39cb293fbad5%2Fb690ln8_processed.png&w=3840&q=75)
Transcribed Image Text:8) Now use the Rectangle class to complete the following tasks:
-
Create another object of the Rectangle class named box2 with a width of 100
and height of 50. Note that we are not specifying the x and y position for this
Rectangle object. Hint: look at the different constructors)
Display the properties of box2 (same as step 7 above).
-
Call the proper method to move box1 to a new location with x of 20, and y of 20.
Call the proper method to change box2's dimension to have a width of 50 and a
height of 30.
Display the properties of box1 and box2.
-
Call the proper method to find the smallest intersection of box1 and box2 and
store it in reference variable box3.
-
Calculate and display the area of box3. Hint: call proper methods to get the
values of width and height of box3 before calculating the area.
Display the properties of box3.
9) Sample output of the program is as follow:
Output - 1213 Module2 (run) x
run:
box1: java.awt. Rectangle [x=10, y=10,width=40,height=30]
box2: java.awt. Rectangle [x=0, y=0,width=100,height=50]
box1: java.awt. Rectangle [x=20, y=20,width=40,height=30]
box2: java.awt. Rectangle [x=0, y=0,width=50,height=30]
Area of intersecting rectangle: 300.0
box3: java.awt.Rectangle [x=20, y=20,width=30,height=10]
BUILD SUCCESSFUL (total time: 2 seconds)
![public class RectangleTest {
3
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Rectangle box1 = new Rectangle(10, 10, 40, 30);
Rectangle box2 = new Rectangle (100, 50);
System.out.println("box 1: + box1);
System.out.println("box 2: + box2);
||
}
}
kg1213debugginglab.Rectangle Test
main
t- 1213DebuggingLab (run) X
run:
box 1: java.awt. Rectangle [x=10, y=10,width=40,height=30]
box 2: java.awt. Rectangle [x=0, y=0,width=100,height=50]
BUILD SUCCESSFUL (total time: 0 seconds)](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6a70e2d2-d641-435a-b212-d4266cff05fc%2Fe300693a-a1f5-4cd2-8ec7-39cb293fbad5%2Fhiffyz2_processed.png&w=3840&q=75)
Transcribed Image Text:public class RectangleTest {
3
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Rectangle box1 = new Rectangle(10, 10, 40, 30);
Rectangle box2 = new Rectangle (100, 50);
System.out.println("box 1: + box1);
System.out.println("box 2: + box2);
||
}
}
kg1213debugginglab.Rectangle Test
main
t- 1213DebuggingLab (run) X
run:
box 1: java.awt. Rectangle [x=10, y=10,width=40,height=30]
box 2: java.awt. Rectangle [x=0, y=0,width=100,height=50]
BUILD SUCCESSFUL (total time: 0 seconds)
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY