1. Homepage
  2. Programming
  3. Assignment 5: Graphic object collection

Assignment 5: Graphic object collection

Engage in a Conversation
Graphic object collectionC++

Assignment5 CourseNana.COM

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? CourseNana.COM

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 CourseNana.COM

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 graphicObjects; //A list that stores graphics, the list should be empty (NOT be null) if there is no graphic parametersfirstsecondthirdSphereradius Coneradiuslength CuboidxyzMethod addObject(ObjectColor objectColor, double ...parameters): Add a graphic to the GraphicObjectCollection according to the parameters. If the length of parameters is 1, then create a Sphere, length of parameters is 2, then create a Cone, and length of parameters is 3, then create a Cuboid. Method getObjectInfo(): Returns the toString() representation of the GraphicObject for each element in the graphicObjects, and sorted by their adding order.Method getObjectCount(): Returns the size of graphicObjects.Method getCountsByColor(): Returns how many objects are under the color sorted in the order defined by the enumeration of colors. If one color has none objects have, skip this color.Format of the string:[Color] [count]Example:RED 2public void addObject(ObjectColor objectColor, double ... parameters); public List getObjectInfo(); public int getObjectCount(); public List getCountsByColor(); Method getObjectByVolume(): Returns the toString() representation of the GraphicObject for each element in the graphicObjects. Sort by ascending order of volume. If the volume is equal, sort by addition order.Method getObjectsBySurface(): Returns the toString() representation of the GraphicObject for each element in the graphicObjects. Sort by ascending order of surface area. If the surface area is equal, sort by addition order.Method getWaterInjected(): There is a container whose volume is the base area times the height, and if put all the elements of graphicObjects in that container and assume that it is possible to do so, how much more water can be injected in that container.Returns the volume of water can be injected.What to submit: GraphicObject.java, Cone.java, Cuboid.java ,Sphere.java,ObjectColor.java, ObjectCollection.java,GraphicObjectCollection.java, and other files you think is necessary. public List getObjectByVolume(); public List getObjectsBySurface(); public double getWaterInjected(double area, double height); CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Graphic object collection代写,C++代写,Graphic object collection代编,C++代编,Graphic object collection代考,C++代考,Graphic object collectionhelp,C++help,Graphic object collection作业代写,C++作业代写,Graphic object collection编程代写,C++编程代写,Graphic object collectionprogramming help,C++programming help,Graphic object collectionassignment help,C++assignment help,Graphic object collectionsolution,C++solution,