Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please please help!! Part B: Create an interface, called Polygon, with the following specifications: Declare three [public] functions called getNumberOfSides, getPerimeter, and getArea. Part C:

please please help!!
Part B: Create an interface, called "Polygon", with the following specifications:
Declare three [public] functions called "getNumberOfSides", "getPerimeter", and "getArea".
Part C: Create an ABSTRACT class, called "Simple_Polygon" (which implements our 'Polygon' interface) with the following specifications:
A protected attribute that's an array of 'Point's, called "vertices".
o Important: For the following class (and remaining parts), how the elements are organized does matter, HOWEVER, to make things more manageable, you can assume that all of this array's points will [always] be organized in a clockwise manner. For examples:
(0, 1) => (1, 1) => (1, 0) => (0, 0) forms a 'square', where as ...
(0, 1) => (1, 0) => (0, 0) => (1, 1) would form a 'hourglass'.
As seen with the latter example, if lines were drawn between [adjacent] points, then we'd have intersecting edges.
You can assume that said scenarios will NEVER occur.
A constructor, with ONE integer parameter, that'll define the 'vertices' attribute with a new array of 'Point's (where it's size is based on said parameter's value).
o Important: If argument is less than 3, throw a 'IllegalArgumentException'.
Implement the [inherited] "getNumberOfSides" function
Define a [public] function called "isEquilateral" which will return true if all of this polygon's sides are of equal length (otherwise it'll return false).
Note: Do NOT worry about having to deal with any approximation errors
o Tip: Invoke our class 'Point's distance function with specific vertices as arguments.
Part D: Create a class called "Triangle", which extends from our 'Simple_Polygon' class, with the following specifications:
A constructor with THREE parameters that are all of data type 'Point'.
The given values must then be assigned into the 'vertices' array (in order).
o Hint: Don't forget to invoke the superclass' constructor
Implement the [inherited] "getPerimeter" function.
o As the name implies, this function should return the total [sum] length between this class' [3] vertices ("A => B", "B => C" and "C => A
Implement the [inherited] "getArea" function.
o As the name implies, this function should return the area that this class' [3] vertices surround. This can be easily found using the following equation:
Legend:
Vertex 1 = (x1, y1), Vertex 2 = (x2, y2), Vertex 3 = (x3, y3)
Formula:
Absolute value of ((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2)
Part E: Create a class called "Quadrilateral", which extends from our 'Simple_Polygon' class, with the following specifications:
A constructor with FOUR parameters that are all of data type 'Point'.
The given values must then be assigned into the 'vertices' array (in order).
Implement the [inherited] "getPerimeter" function.
o As the name implies, this function should return the total [sum] length between this class' vertices ("A => B", "B => C", "C => D" and "D => A").
Legend:
Vertex 1 = A, Vertex 2 = B, Vertex 3 = C, Vertex 4 = D
Formula:
(Area of Triangle 'ABD') + (Area of Triangle 'BCD')
image text in transcribed
Part B: Create an interface, called "Polygon", with the following specifications: Declare three [public) functions called "getNumberOfSides", "getPerimeter", and "getArea". . Note: The return types must [respectively] be 'int', 'double', and 'double'. . Make sure that the name of the first function is spelled with a capital 'O'. Part B: Create an interface, called "Polygon", with the following specifications: Declare three [public) functions called "getNumberOfSides", "getPerimeter", and "getArea". . Note: The return types must [respectively] be 'int', 'double', and 'double'. . Make sure that the name of the first function is spelled with a capital 'O

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago