Question: In geometry, a shape can be defined as the form of an object or its outline, outer boundary or outer surface. Everything we see in









In geometry, a shape can be defined as the form of an object or its outline, outer boundary or outer surface. Everything we see in the world around us has a shape. We can find different basic shapes such as the two-dimensional square, rectangle, and oval or the threedimensional rectangular prism, cylinder, and sphere in the objects we see around us. These geometric shapes appear in objects we see as credit cards, bills and coins, finger rings, photo frames, dart boards, huts, windows, magician's wands, tall buildings, flower pots, toy trains, and balloons. Shapes can be classified into open and closed shapes. Closed geometric shapes can further be put into two broad categories, namely two-dimensional and three-dimensional shapes. The color, overall size, and orientation called the nondefining attributes of a two-dimensional or three-dimensional shape do not define or affect the shape in any way. These attributes can change without any effect on the shape. On the other hand, defining attributes such as the number of sides (parallel or non-parallel, straight or curved), vertices, edges, and faces of a shape, whether the shape is open or closed, and the angle measures determine the shape of a two-dimensional or three-dimensional object. Any change in these defining attributes will change the shape. This assignment will assess your mastery of the following objectives: - To design interface, abstract class, and concrete classes. - To design condition for the comparable class. Rules and Explanations: In this assignment, we only focus on 2D shapes. Create an interface named Shape with prototypes: (The Shape interface must be extended from another interface Comparable) Create an abstract class named AbstractShape that implements the interface Shape. The only method that we need to implement in this class is to compare two Shape objects. The method signature must be public int compareTo(Shape other). The method will determine conditions as follow: 1. Area (please use Heron's formula for triangle) 2. Perimeter 3. Type of shape has the area 8.0 then the square should go before the rectangle. For another example, if a square and a rectangle have the same area and perimeter, the rectangle should go before the square because when we compare the name, rectangle starts with the letter ' r ' and square starts with the letter ' s ', so the letter ' r ' goes before 's'. String class also provides compareTo method, so we can rely on the result of this one. For each concrete class below, we should have one constructor that has no parameter passed in and one constructor that allows user to accept all values from parameters and assign them to the attributes of the class. (We can assume that the point inputs will form valid shapes) 1. Create a concrete class named Triangle with three attributes point1, point2, and point3. Those three points will form a triangle. The data type of those points will be the provided Point class. The class Triangle should extend the abstract class AbstractShape. The toString 0 method should follow the format: \{Type=Triangle, Point1=[Point X=0,Y=0], Point 2=[ Point X=0,Y=0], Point 3=[ Point X=0,Y=0]} 2. Create a concrete class named Rectangle with two attributes top Left and bottomRight. Those two points will form a rectangle. The data type of those points will be the provided Point class. The class Rectangle should extend the abstract class AbstractShape. The toString 0 method should follow the format: \{Type=Rectangle, Topleft=[Point X=0, Y=0], BottomRight=[Point X=0,Y=0]} 3. Create a concrete class named Square with no attribute because it will use attributes from the class Rectangle which it inherited from. In the constructor that accepts no parameter, use only one statement to initiate the attributes of the Square class (super keyword). The second constructor accept the top left point and the length of the side (int primitive data type). Based on those two parameters, create the bottom right point and call the corresponding constructor in the super class that passes in the top left and bottom right points. The toString 0 method should follow the format: \{Type=Square, Topleft=[Point X=0,Y=0], BottomRight =[ Point X=0,Y=0]} 4. Create a concrete class named Circle with one attribute center (Point class) and radius (int primitive data type). The class Circle should extend the abstract class AbstractShape. The toString 0 method should follow the format: \{Type=circle, center=[Point X=0,Y=0], Radius =0} In this assignment, there is a test file provided for sanity check called ShapeMain.java Extra Credit: (N/A) Extra credit is only considered if the assignment submit (and complete) on-time according to original due date on syllabus. The due date is extended will not count. Implementation Guidelines: The program does not compile will receive grade of zero. Place your code in a class named AbstractShape, Triangle, Rectangle, Square, and Circle. - The instructions include: 1. Create an abstract class AbstractShape that implements the interface Shape. There is only one method compareTo need to be implemented in this class. The purpose of this method is to determine if the shape goes before another by comparing the area, perimenter, and the name/type of the shape. 2. Create a concrete class Triangle that only extends the abstract class AbstractShape then implement required methods. 3. Create a concrete class Rectangle that only extends the abstract class AbstractShape then implement required methods. 4. Create a concrete class Square that only extends the concrete class Rectangle then implement required methods. The class should not need to have any extra field because it can rely on the fields of the parent class. 5. Create a concrete class Circle that only extends the abstract class AbstractShape then implement required methods. - Be sure your code follows the naming and coding conventions for the class: 1. Instance fields of a class should be named starting with ' my ' 2. Parameters to methods should be named starting with 'the' 3. Parameters to methods should be specified as final 4. Javadoc comments should be used for the class as well as the methods of the class 5. You will lose points for each of these things on every assignment if you do not adhere to the rules. 6. See this document for specifics (as well as an example): Note: must pass all criterias if using LGS References: Image: https://kidspressmagazine.com/coolmath/printables/geometry/3d-shape-collection.html Resource: https://www.splashlearn.com/mathvocabulary/geometry/shape History: \begin{tabular}{|l|l|l|l|} \hline & Status & File & Note \\ \hline Name & View & & check the design of the dircle class \\ \hline dtshape_c & & & \\ \hline \end{tabular} Courses Not Secure - 18.224.94.128 Assignment 2: View Contest View History Select File Upload File \begin{tabular}{l|l|l|l|} \hline Previous & 1 & 2 & Next \\ \hline \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
