Question: Read instructions very carefully. Java programming language please. Q1 (15 Marks) Create a class named Hexagonthat extends shape class and implements the Cloneableand Comparableinterfaces. The

Read instructions very carefully. Java programming language please.  Read instructions very carefully. Java programming language please. Q1 (15 Marks)
Create a class named Hexagonthat extends shape class and implements the Cloneableand

Q1 (15 Marks) Create a class named Hexagonthat extends shape class and implements the Cloneableand Comparableinterfaces. The comparison should be based on the area of two shapes. Use the following method header: public int compareTo(Shape shp) Assume that all six sides of a hexagon are of equal length. Create appropriate setter and getter method(s) and constructor(s), and override the toString method to return a string representation of all attribute values as well as the area and perimeter of a hexagon object Write a test program that asks the user for the attributes of a Hexagonobject (i.e., side length, color, and filled), creates that object, and then displays its state (side, color, area, etc.). Assume users enter valid inputs. Create a new object using the clone method and compare the two objects using the compareTomethod. After running the compareTol) method, modify one the parameters of the cloned object (for example r2.height) then run the compareTo to check the outcome. Hint: Add "throws Clone NotSupportedException" to the header of the clonemethod as well as the mainmethod in your test program. You will learn more about exception handling in next lecture and lab. Sample run Color: Green Filled (Yes/No)? n Side: 5 First Hexagon color: Green. Not filled. Side: 5.8. Area : 64.9519852838329. Perimeter : 30.0 Clonned Hexagon color: Green. Not filled. side: 5.e. Area: 64.9519052838329. Perimeter: 30. Both Hexagon are identical. Modify the clonned Rec color: Green. Not filled. Side : 15.0. Area: 584.5671475544962. Perimeter: 90. the two Hexagon are different

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!