Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Shapes In this problem, you are provided with a Shape class and will need to create the other four classes shown in the following class

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Shapes In this problem, you are provided with a Shape class and will need to create the other four classes shown in the following class hierarchy. Each shape object has one (x,y) coordinate that anchors it in the xy plane. This anchor point is fixed and cannot change once an object is created. The other parameters can change though. The provided XYCoord class is used to store (x,y) coordinates. All shapes must be able to compute their own area and perimeter 1 in addition to specific methods (outlined below). You are free to add any state to your classes as needed but you should not be storing information twice. Each of the classes will have a constructor that is appropriate for the particular shape detailed as follows: public Quadrilateral (XYCoord a, XYCoord b, XYCoord c, XYCoord d) // a quadrilateral has four straight sides and four corner points (vertices) // the corner points are specified by the inputs a,b, c,d // a is the anchor coordinate for this shape. public Square(XYCoord anchor, double length) // a square is a special quadrilateral (all sides have the same // length and the angle at each corner is 90 degrees). // the anchor is the bottom-left corner of the square and length >=0 public Triangle(XYCoord a, XYCoord b, XYCoord c) // a,b, are the three coordinates of the corners (vertices) of the triangle // a is the anchor coordinate for this shape public Circle(XYCoord centre, double radius) // centre is the anchor coordinate and radius >=0 1 The word circumference is usually used circle and shapes with curves but we will use perimeter for everything You will also need to create the following setter methods in the specified classes. Note that there is no setter for the Quadrilateral class.: Circle Class public void setRadius (double newRadius) // changes the object's radius to be newRadius Triangle Class public void setBC (XYCoord newB, XYCoord newC) // changes the object's b and c points to be newB and newC Square Class public void setLength (double newLength) // changes the object's length to be newLength You can use the provided ShapeExampleApp to help test your code. Do NOT change or submit the provided Shape.java file. Do NOT change or submit the provided XYCoord.java file. When testing, we will use the files as provided (and delete any version you submit). The area for the square and circle should be straightforward to compute. For the quadrilateral, note that you can think of this shape as being composed of two triangles next to each other. For a triangle, you might find the following resource helpful: https://byjus.com/maths/ area-of-a-triangle/ Include your Quadrilateral. java, Square. java, Triangle.java and Circle.java files in your .zip when you submit. Note that the shapes will always be created with coordinates as shown below. That is, the ordering of the coordinates will correspond to the labelling on the diagrams. ublic class ShapeExampleApp \{ private static double epsilon =0.0000001 I/ private helper methods for the program private static boolean eq(double x double y ) return Math. abs (xy)

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 Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago