Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me code this and create tests in JAVA!! In this assignment, we will be going over the application of polymorphism. Polymorphism is one

Please help me code this and create tests in JAVA!!
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
In this assignment, we will be going over the application of polymorphism. Polymorphism is one of the three main principles of Object-Oriented Programming and describes situations in which something occurs in several forms. (see references for more information) P Notes on Shapes O Ellipse \& Circle An ellipse is basically nothing but an elongated circle. A circle has a radius. An ellipse has two measurements: the major axis (a) and the minor axis (b) with a>b. Note that in an ellipse if a=b then it becomes a circle. The measure of "roundness" of an ellipse is given by its eccentricity e where the value of e is always between 0 and 1. Note for a circle e=0. The higher the value of e, the higher is the deviation of the ellipse from its roundness. Eccentricity is associated with a lot of other shapes as well e.g. hyperbola, parabola, etc. We defined an interface called Eccentric for all eccentric shapes. N Regular Sided Polygon A regular polygon is a shape that has all angles and side lengths equal. A regular polygon has the property that if you know the length and number of sides, you can instantly find the perimeter and area of any regular polygon. P Octagon, Square, \& EquilateralTriangle These shapes are 8,4 and 3 sided regular polygons respectively. Since oll their sides are equal, their constructors will have only one parameter. These classes should call the super class (nSidedRegularpolygon) to calculate there perimeter and area. - Required Tasks P Implement means to create the test, then the code, and fix your issues. You must do the following in onder to complete this assignment: 1. Complete the Ellipse class. 2. Design and implement nSidedRegularPolygon. Use the Ellipse class as a reference. - Note: Sides should come first in your constructor 3. Complete Octagon, Square, EquilateralTriangle by extending nSidedRegularPolygon. If implemented correctly all 3 Classes should be able to call the super class for area and perimeter. It is recommended you start with octagon, as it has some methods ready-to-go. 4. In the constructor of each class and using GeoColors Enum, set Octagons color to Purple, Square to green, and EquilateraiTriangle to red. You will need to switch color to protected in the GeometricObject.java file. This will allow all extending classes to override the color attribute. 5. Override the toString method in every class to correctly output the class name and the pertinent attributes. - Ensure that the end of your toString ends with from the super class. to include the output 6. All classes in objects2d must implement the Comparable and Cloneable interfaces. Ensure you implement all methods that need overloaded (compareTo, clone, and equals). Use the Circle Class for help when implementing compareTo, clone, and equals methods throughout this assignment Notes: - You must have toString Implemented to be able to get the correct equals output. - There are few test files with tests that are commented out. THESE TESTS WORK AFTER YOU IMPLEMENT THE METHODS THEY USE. They will give you an error otherwise, which is why they are temporarily commented out. The octagon class also has portions of its code commented out until you implement the nSidedRegularPolygon class. Uncomment and use them :), - Have at least 2 unit tests for every method for ALL classes. - Enums - Interfaces - objects2d c Circle (c) Ellipse (C) EquilateralTriangle (c) nSidedRegularPolygon (c) Octagon C Square test java - objects2dTest > - Circle > E Ellipse > - EquilateralTriangle v - nSidedRegularPolygon (c) clone (C) compareTo (C) equals (c) getArea (c) getPerimeter (c) toString > - Octagon > - Square (c) GeometricTest

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Check that you have given a brief background statement.

Answered: 1 week ago

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago