Question
Your task is to write a program that will output colored shape vertices in CSV format (comma-separated value ; something Microsoft Excel can open!). To
Your task is to write a program that will output colored shape vertices in CSV format (comma-separated value ; something Microsoft Excel can open!). To build up to this capability, you will be implementing a set of classes, including two subclasses. Here is the recommended sequence: 1. To start, implement the Point2D class. It is quite similar to the class in a previous assignment, but now has you override the equals method to detect points that represent the same location, within a distance threshold. 2. Then implement the Rectangle class, which is a subclass of Shape2D (provided for you). You will use simple arithmetic to implement such functionality as computing area, perimeter, and center point. The vertices (think corner points) for a rectangle are expected to start at the lower-left corner and proceed clockwise. Two rectangles are considered equal if they have lower-left and upper-right points that are equal. 3. Now move on to the Triangle class, which is also a subclass of Shape2D. The math here can get a little more complex for area and center point (centroid ). An axis-aligned bounding box (AABB ) is simply the rectangle that most closely bounds the vertices of the triangle. The vertices should be returned in the order they were provided in the constructor. 4. Now move on to the PA4b class. The shapeVertices method receives an array of Shape2D objects and must produce a string which includes all the vertices in CSV format (on each line: "color",x,y). If the method encounters a triangle object, it should include the vertices of the AABB after the triangle. This is an opportunity to experiment with polymorphic code. When this method is complete, proceed to main validate command-line arguments for a single colored triangle and use the method you just completed to output the corresponding CSV to the terminal. Here are example runs of a completed program: $ java edu.wit.cs.comp1050.PA4b Please supply correct inputs: color x1 y1 x2 y2 x3 y3 $ java edu.wit.cs.comp1050.solution.PA4b blue 0 0 0 1 1 0 "blue",0.000,0.000 "blue",0.000,1.000 "blue",1.000,0.000 "blue",0.000,0.000 "blue",0.000,1.000 "blue",1.000,1.000 "blue",1.000,0.000 Note: if you copy-paste the output into a file (typically with a .csv extension) and open it in Excel, you could then plot the last two columns using an XY plot!
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