basic java code, self-learner here so pls do use more // comments ya if needed pls label the solution with the question label Just needed the the question b &c , a I have done

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 6SA
icon
Related questions
Question

basic java code, self-learner here so pls do use more // comments ya if needed

pls label the solution with the question label

Just needed the the question b &c , a I have done 

Question 3
(a) Design a class named Point with two private attributes x and y of type int for the
coordinates x and y of a point. The class has a toString method that returns
"Coordinates (4,10)" where 4 and 10 are the attributes x and y.
(b) Continue from (a), design a class named Rectangle with attributes Point, width
and length. Create a constructor that receives x, y, width and length as
parameters to initialize the object. The class has a method named area that returns the
area of the rectangle object. The formula for area is width * length.
The class also has a method named getLowerRight Point which returns the
coordinates of the lower right point of the rectangle. The lower right coordinate is
calculated based on the Point and the width and length. Coordinate x of the lower right
point is coordinate x of Point + width. Coordinate y of the lower right point is coordinate
x of Point - length.
Point (x,y)
X
2
20
width
y
10
85
(c) Create an array to store the following Rectangle objects which created in part (b):
length
6
12
length
width
8
20
LowerRightPoint (x,y)
Write a loop to iterate the array and display the Point's coordinates, area and the
coordinates of the lower right corner of the rectangle.
Transcribed Image Text:Question 3 (a) Design a class named Point with two private attributes x and y of type int for the coordinates x and y of a point. The class has a toString method that returns "Coordinates (4,10)" where 4 and 10 are the attributes x and y. (b) Continue from (a), design a class named Rectangle with attributes Point, width and length. Create a constructor that receives x, y, width and length as parameters to initialize the object. The class has a method named area that returns the area of the rectangle object. The formula for area is width * length. The class also has a method named getLowerRight Point which returns the coordinates of the lower right point of the rectangle. The lower right coordinate is calculated based on the Point and the width and length. Coordinate x of the lower right point is coordinate x of Point + width. Coordinate y of the lower right point is coordinate x of Point - length. Point (x,y) X 2 20 width y 10 85 (c) Create an array to store the following Rectangle objects which created in part (b): length 6 12 length width 8 20 LowerRightPoint (x,y) Write a loop to iterate the array and display the Point's coordinates, area and the coordinates of the lower right corner of the rectangle.
Expert Solution
steps

Step by step

Solved in 5 steps with 7 images

Blurred answer
Knowledge Booster
Block Comments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr