Question: Write a java program: Write a concrete class named Hexagon. Assume all six sides of the hexagon are of equal size. Your class should include

Write a java program:

Write a concrete class named Hexagon. Assume all six sides of the hexagon are of equal size. Your class should include the following:

A private double data field side. A no-arg constructor that creates a hexagon with the data field side initialized to 1.0. A constructor that creates a hexagon with the specified side. The setter and getter methods for the data field side. A method named getPerimeter() that returns the perimeter of the hexagon (side * 6). Your class should also

Override the equals method. Two hexagons are equal if they have the same side. Override the toString method that returns a string description for the hexagon. Implement the Comparable interface. (Compare two hexagons based on their perimeters.) Implement the Cloneableinterface.

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 Programming Questions!