Assignment5
Description Alice is a graphic enthusiast. For each graphic, there are different ways to calculate the surface area and volume of the graphic. Alice wants to make a graphic object collection so that she can query and compare different graphs more conveniently. Can you help her to design the graphic object collection?
Question 1: GraphicObject [40 points] ObjectColor It is enum class as below, which is an attribute of GraphicObject. You can add attributes, methods in it if you need, but you do not modify the name of its constant objects.GraphicObject Description: There are three types of graphic as Cone, Cuboid and Sphere. In this question, you are going to complete abstract class GraphicObject and implement subclasses Cone, Cuboid and Sphere based on the class GraphicObject.Fields in GraphicObject: Fields in subclass Cone: Fields in subclass Cuboid:public enum ObjectColor { RED, YELLOW, BLUE, GREEN, BLACK, WHITE;} private ObjectColor color; //Every graphic has the color, you should use the enum ObjectColor.private int id; //Every graphic has an id and the id is unique for each graphicprivate double radius; private double length; //for all test data, the length is larger than radius
Fields in subclass Sphere:Method in GraphicObject: surfaceMeanSize Those three subclasses should implement it.Calculates the surface area of each graphic.Return:return the surface area of each graphic.Method in GraphicObject: volume Those three subclasses should implement it.Calculates the volume of each graphic.Return:return the volume of each graphic.Method toString in those three subclasses: Return:A string that describe the information of the graphic object as the format below. For Cone:Format:Cone: r=[radius], l=[length]example: round to two decimalsprivate double x; //The length of cuboidprivate double y; //The width of cuboidprivate double z; //The height of cuboidprivate double radius;
public abstract double surfaceMeanSize();
public abstract double volume();
public String toString();
Cone: r=2.00, l=3.00
For Cuboid:Format:Cuboid: x=[x], y=[y], z=[z]example:round to two decimalsFor Sphere:Format:Sphere: r=[radius]example:round to two decimalsHint: The class names should be same as requirements. Do not modify or remove any fields or methods that have been already defined. You can add other classes, fields and methods if you need. You can also override superclass' methods if necessary.What to submit: GraphicObject.java, Cone.java, Cuboid.java ,Sphere.java,ObjectColor.java and other files you think is necessary.Question 2: ObjectCollection [60 points] Description: In this question, you are going to build a class GraphicObjectCollection to implement the interface ObjectCollection. You need to implement all abstract methods defined in ObjectCollection.Fields: Cuboid: x=2.00, y=1.50, z=4.00
Sphere: r=2.50
private List