Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm programming in java using eclipse, and im trying to take the code I created and Adding another main class named Final.Java to produce the

I'm programming in java using eclipse, and im trying to take the code I created and Adding another main class named Final.Java to produce the output in the image below with the plots 1-4. I have attached all the code needed to make the final class below besides tester.Java because I used to class to make sure the program worked. I have also attached the after the code the first page to the second one just in case you dont fully understand what my code is doing. I also have a bonus problem to translate Final.java and the other code i Did into the output on the 3rd image using JavaFX. Any help will be appriciated because im stuck.image text in transcribed

GeometricObject.Java:

public abstract class GeometricObject {

private String color = "white"; // shape color

private boolean filled; // fill status

protected GeometricObject() { // POST: default shape is unfilled blue

this.color = "blue";

this.filled = false; }

// POST: shape set by user

protected GeometricObject(String color, boolean filled) {

this.color = color;

this.filled = filled;

}

// accessors and modifiers

public String getColor() { return color; }

public void setColor(String color) { this.color = color; }

public boolean isFilled() { return filled; }

public void setFilled(boolean filled) { this.filled = filled;

}

public String toString() { // POST: string representation of shape

return "color: " + color + " filled: " + filled;

}

public abstract double getArea(); // POST: return area of geometric object

public abstract double getPerimeter(); // POST: return perimeter of geometric object

}

Point.Java:

public class Point {

private double x ; // x coordinate

private double y; // y coordinate

public Point ( ) // POST: point (0,0)

{ x = y = 0; }

public Point (double x, double y) // POST: point (x,y)

{ this.x = x;

this.y = y; }

// accessors and modifiers

public double getX() {

return x; }

public void setX(double x) {

this.x = x; }

public double getY() {

return y; }

public void setY(double y) {

this.y = y; }

public String toString() // POST: return (x,y)

{ return " (" + x + "," + y + ") "; }

}

Rectangle.Java:

public class Rectangle extends GeometricObject{

private double width;

private double height;

public Rectangle() {

super();

width = 2.0;

height = 1.0;

}

public Rectangle(double width, double height, String color, boolean filled) {

super (color,filled);

this.width = width;

this.height = height;

}

public double getWidth() {

return width;

}

public void setWidth(double width) {

this.width = width;

}

public double getHeight() {

return height;

}

public void setHeight(double height) {

this.height = height;

}

@Override

public double getArea() {

return width * height;

}

@Override

public double getPerimeter() {

return ((2 * width) + (2 * height));

}

@Override

public String toString ( ) {

return super.toString() + " height: " + height + " width: " + width + " area: " +

String.format("%-6.2f",getArea()) + " perimeter: " + String.format("%-10.2f",getPerimeter());

}

}

Rectangle2D.java:

public class Rectangle2D extends Rectangle {

private Point upperLeft;

public Rectangle2D()

{

super();

upperLeft = new Point(0,0);

}

public Rectangle2D(double x, double y,double width, double height)

{

super(width, height, "white", false);

upperLeft = new Point(x, y);

}

public Rectangle2D(double x, double y,double width, double height, String color, boolean filled)

{

super(width, height, color, filled);

upperLeft = new Point(x, y);

}

public Point getUpperLeft()

{

return upperLeft;

}

public String toString()

{

return super.toString() +" upper left: " + upperLeft;

}

public boolean contains(Point other)

{

if(upperLeft.getX()

{

if(upperLeft.getY()

return true;

}

return false; //for all other cases

}

public Boolean contains (Rectangle2D other)

// POST: return true if object contains other rectangle

{

//compute the lowerRight corner of the other rectangle

Point lowerRight = new Point(other.upperLeft.getX() + other.getWidth() , other.upperLeft.getY() + other.getHeight());

//only if this rectangle contains both the upper left and lower right corners of the other rectangle,

//the other rectangle is fully contained in this rectangle

if(contains(other.upperLeft) && contains(lowerRight))

return true;

else

return false;

}

public Boolean overlaps (Rectangle2D other)

// POST: return true if other overlaps object

{

//calculate the 3 other corners of the other rectangle

Point lowerRight = new Point(other.upperLeft.getX() + other.getWidth() , other.upperLeft.getY() + other.getHeight());

Point upperRight = new Point(other.upperLeft.getX() + other.getWidth() , other.upperLeft.getY() );

Point lowerLeft = new Point(other.upperLeft.getX() , other.upperLeft.getY() + other.getHeight());

//there is an overlap if any of the 4 corners of the other rectangle are contained in this rectangle

if(contains(other.upperLeft) || contains(lowerRight) || contains(upperRight) || contains(lowerLeft))

return true;

else

return false;

}

}

image text in transcribed

Bonus: If possilble Id like to take all the code and make this output in the image below using JavaFX.

image text in transcribed

2, Version 1: Test the Rectangle2D class thoroughly. A test program A1Tester.java is provided on Blackboard. (Note: if you do not complete the application submit a jar file of the tester for partial credit for completing the Rectangle2D class.) 3. Write a console application that uses the Rectangle2D class. A field (20 points each direction) is filled randomly with small plots (4 points each direction) that are contained within it and do not overlap. This problem should be solved with the Rectangle2D class; do not use a 2D array of characters to represents the field. 4. Create two sample screen shots. Output lists your name, the start coordinates of each plot as shown below, and a grid using P for a plot and period. otherwise. Paste the two screenshots into a single document to staple to this cover sheet. Your name goes here Your name goes here Plot 1: (14.8,5.0) Plot 2: (13.0,11.0) Plot 3: (8.0,8.0) Plot 4: (3.0,15.0) Plot 1: (2.0,6.0) Plot 2: (16.0,2.0) Plot 3: (10.0,1.e) Plot 4: (8.8,9.e) 2, Version 1: Test the Rectangle2D class thoroughly. A test program A1Tester.java is provided on Blackboard. (Note: if you do not complete the application submit a jar file of the tester for partial credit for completing the Rectangle2D class.) 3. Write a console application that uses the Rectangle2D class. A field (20 points each direction) is filled randomly with small plots (4 points each direction) that are contained within it and do not overlap. This problem should be solved with the Rectangle2D class; do not use a 2D array of characters to represents the field. 4. Create two sample screen shots. Output lists your name, the start coordinates of each plot as shown below, and a grid using P for a plot and period. otherwise. Paste the two screenshots into a single document to staple to this cover sheet. Your name goes here Your name goes here Plot 1: (14.8,5.0) Plot 2: (13.0,11.0) Plot 3: (8.0,8.0) Plot 4: (3.0,15.0) Plot 1: (2.0,6.0) Plot 2: (16.0,2.0) Plot 3: (10.0,1.e) Plot 4: (8.8,9.e)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2 What are the key barriers to implementing HRM?

Answered: 1 week ago

Question

1 What are three of the formative traditions in HRM?

Answered: 1 week ago