Question
(JAVA) I was wondering if I can get some help implementing this image into code. Thank you so much in advance! Write the Polygon interface
(JAVA)
I was wondering if I can get some help implementing this image into code. Thank you so much in advance!
Write the Polygon interface and two classes (Triangle and Rectangle).
You can reuse Point in Java API or define your own.
Implement getPoints() and getArea() in the two subclasses.
Use Herons formula to compute a triangles area.
The area of a triangle = Sqrt(s(s-a)(s-b)(s-c))
where s = (a + b + c) / 2
a, b and c are the lengths of the triangles sides.
Write test code (in main() or with JUnit) that
Makes two different triangles and two different rectangles,
Contains those 4 polygons in a collection (e.g. ArrayList),
Use generics and an iterator
Prints out each polygons area.
Take advantage of polymorphism.
Polygon > AreaCalculator - points: ArrayList
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started