Hey guys, this is my first post and probably (as usual), within my first post, I need help. I'm supposed to be doing a project for my beginning Java class, but the teacher is rather, lacking. I was hoping that someone here could help me.

His outline says to (for the first half, at least):

1. Construct a rectangle whose top-left point coordinates are (40,60) and whose width is 100 and height is 80.

2. Construct a smaller concentric rectangle with the parameters to the constructor deﬁned relative to those of the ﬁrst rectangle. Both rectangles should be such that the width of the path between the two rectangles is uniformly 10 units. (Note: No argument to this constructor should be a constant.)

3. Using appropriate methods, print the coordinates of the vertices of each rectangle in the form {(x1, y1), (x2, y2), (x3, y3), (x4, y4)}, where the coordinates represent the vertices of the top-left, top-right, bottom-right, and bottom-left corners. Use a label to indicate which rectangle’s coordinates are printed. Also, using appropriate methods, calculate and print the area of the path between the two rectangles (Hint: subtract the areas of the rectangles.)

I can construct the rectangle with the proper coordinates and all, but I stumble around and I'm having a REALLY hard time finding out how to get the second rectangle to use the first's points as a reference. His notes give different documentation than the book which give different documentation than anything I could find online.I've tried a bunch of different stuff. I'll upload my coding so far.. it's clunky. I thought I had the second part down, so I started to try to get it to display the coordinates, but I just broke it further.

tl;dr Questions:

1. How do I get a rectangle to reference a different rectangle's points as its own (Plus or minus a few pixels)?

2. How do I print out the location of the other corners of the rectangle that aren't the origin?

Quote:

package rectangles;
import java.awt.*;
public class RectangleTester
11 {
12 public static void main(String[] args) {
13 Rectangle rectOne = new Rectangle(40, 60, 100, 80);
14 Rectangle rectTwo = new Rectangle((int)rectOne.getX()+10,(int)rectOne.getY()+10,(int)rectOne.getWid th()-20,(int)rectOne.getHeight()-20);
15
16 System.out.println("The coordinates of the bigger rectangle are: " + rectOne.getX());
17
18 System.out.println("The coordinates of the smaller rectangle are: " + rectTwo.getX());
19 }
} |

So, my code is now "error free", but I'm still not sure how to reference the other parts of the rectangle (Right lower and bottom corners and left lower).