PRO192_-_PE02_-_SU_2024_2181.webp
G

PRO192_-_PE02_-_SU_2024_2181.webp

3 of 4
Paper No: 1
-color:String
+Shape()
Shape(): default constructor to set color is 'Black'
Shape(color:String): parameterized constructor,which sets value to color
+Shape(color:String)+getColor():String
getColor():String - return the color.
+setColor(color:String):void
setColor(color:String):void - set the color of Shape.
+calArea():double
calArea():double - the abstract method will be implemented in subclass
+calPerimeter():double
calPerimeter():double - the abstract method will be implemented in subclass
Triangle
Where:
-a :double
-b:double
Triangle(color:String, a: double, b:double, c:double) - parameterized constructor, which sets values to color,a, b, and c (a, b, c are edges of the Triangle)
-c :double
is ValidData(): boolean- return true if a, b, and e are valid sides of the triangle, otherwise return false. The a, b, and c are valid sides if each value is less than the sum of the others (a<b+c, ba+c, c<a+b)
+Triangle(color:String, a:double,b:double, c:double)
+isValidData(): boolean
+calPerimeter():double
calPerimeter():double return the perimeter of the triangle with perimeter = a+b+c. If a, b, c are invalid sides of the triangle then return 0
+calArea():double
calArea():double - returns the area of the triangle.Using Heron's formula:a+b+c
+toString(): String
Zoom
p=s=p(pa) (pb)(p-c)and you can use the square root function like this:Math.sqrt(). If a, b, c are invalid sides of the triangle then return 0
toString(): String - return a string format of the triangle such as: color,a,b,c with a, b, c are formatted in two decimal places

+ 93%
Close
Chưa có bình luận nào.

Thông tin

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

Image metadata

Filename
PRO192_-_PE02_-_SU_2024_2181.webp
File size
219.3 KB
Dimensions
1920px x 859px

Share this media

Back
Bên trên Bottom