In Java, please. This is the code I have so far:
```java
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Rectangle2D r1 = new Rectangle2D();
Rectangle2D r2 = new Rectangle2D();
System.out.println("Type in your x value.");
double xValues = 2; //input.nextDouble();
System.out.println("Type in your y value.");
double yValues = 1; //input.nextDouble();
System.out.println("Type in your width.");
double w = 5; //input.nextDouble();
System.out.println("Type in your height.");
double h = 6; //input.nextDouble();
r1.setX(xValues);
r1.setY(yValues);
r1.setHeight(h);
r1.setWidth(w);
System.out.println(r1);
}
class Rectangle2D {
private double x;
private double y;
private double width;
private double height;
Rectangle2D() {
x = 0;
y = 0;
width = 1;
height = 1;
}
Rectangle2D(double xValue, double yValue, double w, double h) {
x = xValue;
}
public void setX(double xValues) {
x = xValues;
}
public double getX() {
return x;
}
public void setY(double yValues) {
y = yValues;
}
public double getY() {
return y;
}
public void setWidth(double w) {
width = w;
}
public double getWidth() {
return width;
}
public void setHeight(double h) {
height = h;
}
public double getHeight() {
return height;
}
@Override
public String toString() {
return "The area of the rectangle is: " + getArea() + " and the perimeter is: " + getPerimeter();
}
public double getArea() {
return height * width;
}
public double getPerimeter() {
return 2 * (width + height);
}
public boolean contains(double x, double y) {
}
public boolean contains(Rectangle2D rectangle) {
}
}
```
Create a Java public class inside a .java named FirstnameLastnameLab2 using your own first and last names.
In the same .java file, design a private class named Rectangle2D that contains:
- Two double data fields x and y that specify the center of the rectangle
- Two double data fields width and height.
- A no-arg constructor that creates a default rectangle with (0,0) for (x, y) and 1 for both width and height.
- A constructor that creates a rectangle with a specific x, y, width, and height
- Accessor and mutator methods (Getters and Setters) for all data fields
- A toString method to print the object
- A method named getArea that returns the area of the rectangle
- A method named getPerimeter that returns the perimeter of the rectangle
- A method named contains(double x, double y) that returns true if the specified point is inside the rectangle.
- A method named contains(Rectangle2D rectangle) that returns true if the rectangle specified by the caller is inside this rectangle
In your public class called FirstnameLastnameLab2, create a main method that tests your Rectangle2D class by doing the following items in order:
1. Create a default rectangle object named rl.
2. Allow the user to set the values for a rectangle object named r2.
3. Print the area and perimeter of each rectangle.
4. Test to see if rl contains r2 and output the result.
5. Allow the user to specify a point to see if it is inside rl or r2 and output the result.
6. Print both rl & r2.
7. Allow the user to change the data field values for rl.
8. Repeat steps 3, 4, and 5 above.
9. Print both objects again.