Question: Submit Hexagon.java to model the concept of a hexagon, that meets the following specifications: (there should be no need for static anything in the Class)
Submit Hexagon.java to model the concept of a hexagon, that meets the following specifications:
(there should be no need for static anything in the Class)
1. Two (and only two) private fields:
private Point center; // required to be center of the hexagon
private double side; // the length of one side (all six are same)
2. With two constructors:
Default constructor (set all field data to zeroes)
public Hexagon(Point c, double s) // use Point from java awt
3. The usual accessors and mutators:
public Point getCenter();
public double getSide();
public void setCenter(Point c);
public void setSide(double r);
4. Create a couple more useful methods:
public double area(); // returns area (Google has formula)
public double perimeter(); // return perimeter (very simple math)
5. Follow my Class submission requirements Class (data structure) Submission Requirements For example:
// Client tests the Class we've made Hexagon h1 = new Hexagon(new Point(82,92),10); h1.setSide(50); h1.area(); // returns 6495.19 h1.perimeter(); // returns 300.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
