Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with implementing test cases for this assignment in JAVA!! In this assignment, we will be going over the application of polymorphism. Polymorphism is

Please help with implementing test cases for this assignment in JAVA!!
image text in transcribed
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 > * Ellipse > - EquilateralTriangle - nSidedRegularPolygon (c) clone (C) compareTo C equals (C) getArea (c) getPerimeter (c) toString > - Octagon > - Square c) GeometricTest ublic class nSidedRegularPolygon extends Geometricobject \{ / * The number of sides (N) for this nSidedRegularPolygon object */ no usages private int sides; no usages new* int getsides()\{ return 0 ; \& ** * The zength of alz the sides no usages private double sidelength; no usages new* double getsidelength()\{ H return 0

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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions