Computers and Technology
Computers and Technology, 22.07.2019 19:10, Jana1517

Public class: shapetests
package-visible class(es): octagon, triangle, illegaltriangleexception
write a class named octagon that extends geometricobject and implements the comparable and cloneable interfaces. assume all eight sides of the octagon are of equal length. the area can be computed using the following formula:
area = (2 + 4/ √ 2) ∗ side ∗ side
define the octagon class to have a private, double data field named side with its getter and setter methods.
define a no-arg constructor that creates an octagon with side 0, and a constructor to create an octagon with a specified side. implement the getarea and getperimeter methods, as is required.
define the triangle class derived from geometricobject to represent a geometric object with three sides. in a valid triangle, the sum of any two sides is greater than the other side. the triangle class must adhere to this rule. create the illegaltriangleexception class, and modify the constructor of the triangle class to throw an illegaltriangleexception object if a triangle is created with sides that violate the rule, as follows:
/** construct a triangle with the specified sides */
public triangle(double side1, double side2, double side3)
throws illegaltriangleexception {
// implement it }
implement the getarea and getperimeter methods for the triangle class, as is required.
draw a uml diagram that involves octagon, triangle, geometricobject, comparable, and cloneable. include a png of the class diagram as part of your submission.
finally, write a test program that creates an array geometricobject[] shapes containing 3 octagon objects and 3 triangle objects. create one of the octagon objects by calling the clone method on an existing octagon, and compare the two objects using the compareto method. write a loop that sums the area of all the geometric objects in the array by calling the overridden getarea method on each object.

answer
Answers: 3

Similar questions

Do you know the correct answer?
Public class: shapetests
package-visible class(es): octagon, triangle, illegaltriangleexcept...

Questions in other subjects:

Konu
Mathematics, 04.10.2020 09:01
Konu
Biology, 04.10.2020 09:01