PRO192_-_FA_2023_-_PE_940.webp
Mỹ Hạnh1

PRO192_-_FA_2023_-_PE_940.webp

Circle (x: int, y: int, radius: double)
-----Use
setRadius(radius: double)
+ main(args: String[]): void
getRadius(): double
getDiameter(): double
+ getCircumference(); double
getArea(): double
+ toString(): String
Base on given class diagram, create all classes
[40 points]
1. Class Point
Declare fields of class
Constructor: set x=value of x, y=value of y.
Get methods for x and y.
Set methods for x and y.
toString method: will return a string that contains coordinates of Point with format:
Point{x=xValue,y=yValue}
For example, a point with x=3 and v=4. so that toString() method will return a string as
below:
Point( c=3 y=4\}
2. Class Circle
Declare fields of class
Default constructor will create base object Point(0,0) and set radius=1.
Constructor: create base object Point(x,y) and set radius-value of radius.
Get methods for radius.
Set methods for radius.
getDiameter() method will return the diameter of circle based on circle's radius.
getCircumference() will return the circumference of circle.
getArea() will return area of circle.
toString() method will return a string that contains: coordinate of circle's center, radius,diameter, circumference and area of circle:Circle(Center{x=xValue,y=yValue), radius=radiusValue, diameter diameterValue,c
ircumference=circumferenceValue , area=areaValue)For example, a circle with x=3. y=4, radius=2.5, diameter 5.0, circumference=15.71 and area=19.63, so that toString() method will return a string as below:
Circle (Center(x=2, v=4y , radius=2.5, diameter 5.0,circumference=15.71,area=19.6 3)
  • Like
Reactions: Tamoverflow
Chưa có bình luận nào.

Thông tin

Category
PRO192
Thêm bởi
Mỹ Hạnh1
Ngày thêm
Lượt xem
5,429
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRO192_-_FA_2023_-_PE_940.webp
File size
128.7 KB
Dimensions
1552px x 626px

Share this media

Back
Bên trên Bottom