Question: THIS PROGRAM IS IN JAVA PLEASE MAKE SHAPE CLASS AND CIRCLE CLASS. I AM HAVING TROUBLE WITH BOOLEAN AND HASHCODE. For this assignment you will

THIS PROGRAM IS IN JAVA

PLEASE MAKE SHAPE CLASS AND CIRCLE CLASS. I AM HAVING TROUBLE WITH BOOLEAN AND HASHCODE.

For this assignment you will build a simple inheritance hierarchy of shapes. The hierarchy is as follows:

A Shape class (you can rename it to AbstractShape to get rid of style error) that has the following items:

public abstract double area(): will return the area of a given shape this method will have no code in it (it will be abstract) public abstract String name(): will return the shape name this method will have no code in it (it will be abstract) public String toString(): will return a String containing the name of the shape along with its area as follows: Name: , Area: implements the Comparable interface and provides an implementation for the public int compareTo(final Shape theOtherShape) behavior/method. This method should compare the current shape to the one passed in to the method. It must first compare by name, then by area if the names are the same. Be sure and use generics to specify you are comparing against another Shape when you implement this interface. overrides the equals method inherited from Object (public boolean equals(final Object theOtherObject)) it should use getClass() to see if current instance is the same class as otherObject --do not use instanceof All shape classes listed below must implement this Shape class All shape classes listed below must provide an override for the public int hashCode() method inherited from Object

Circle class that has the following: extends the Shape class (and thus must provide implementations of the area() and name() methods) An instance field for the radius that is final A package level constructor that is passed a radius The constructor must make sure this value is greater than 0 or throw an IllegalArgumentException with specific information about what was wrong with the value (e.g. it was not greater than 0 and show the actual value) A public get method to return the radius The class must be final

CIRCLE CLASS MUST PROVIDE AN OVERRIDE FOR PUBLIC INT HASHCODE.

ShapeFactory class that has the following:

Static methods to create Circle, Square, Triangle, and Rectangle

Those static methods should accept parameters necessary to call the constructors for each of the classes

ALL THE ABOVE ITEMS MUST BE IN A PACKAGE NAMED shapes

ShapeTester class that has the following:

Is placed in a package called controller

Creates at least 5 shapes of each type using the ShapeFactory and places them in an ArrayList of type Shape

The 5 shapes of each type should have at least two of those shapes with the same data (e.g. two Circles with the same radius, etc.)

Prints the ArrayList of shapes, preceded by a message specifying that the shapes are being printed before sorting

Make sure what you print is nicely formatted and easy to read

Sorts the ArrayList of shapesYou can use a sort method from the Java API or write one of your own

If you write your own sort method you may only use the compareTo method provided by the shapes

Prints the ArrayList of sorted shapes, preceded by a message specifying the shapes have been sorted

Make sure what you print is nicely formatted and easy to read.

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!