ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Problem b (PA4b.java) Your task is to write in JAVA program that will output colored shape vertices in CSV format (comma-separated value[1];…

by | Nov 28, 2023 | engineering

Problem b (PA4b.java)

Your task is to write in JAVA program that will output colored shape vertices in CSV format (comma-separated value[1]; 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[2] and center point (centroid[3]). An axis-aligned bounding box (AABB[4]) 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!

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!