我正在尝试编译此定义,但我不断收到错误消息。错误提示:发现 1 个错误:File: C:\Users\GreatOne\Desktop\Master Folder\04 (j)\04 - Copy\ObjectDemo2\CreateObjectDemo.java [line: 32] Error: origin cannot be resolve to a variable
/**
* This class offers a main method to create and use sample Point and Rectangle objects.
*/
public class CreateObjectDemo {
public static void main(String[] args) {
// Create a point object and two rectangle objects:
Point origin_one = new Point(23, 94);
Rectangle rect_one = new Rectangle(origin_one, 100, 200);
Rectangle rect_two = new Rectangle(50, 100);
// Display rect_one's width, height, and area:
System.out.printf("Width of rect_one: " , rect_one.width);
System.out.printf("Height of rect_one: " , rect_one.height);
System.out.printf("Area of rect_one: " , rect_one.area());
// Set rect_two's position:
rect_two.origin = origin_one;
// Display rect_two's position:
System.out.printf("X Position of rect_two: " , rect_two.origin.x);
System.out.printf("Y Position of rect_two: " , rect_two.origin.y);
// Move rect_two and display its new position:
rect_two.move(40, 72);
System.out.printf("X Position of rect_two: " , rect_two.origin.x);
System.out.printf("Y Position of rect_two: " , rect_two.origin.y);
}
// A method for moving the rectangle:
public void move(Point newOrigin) {
origin = newOrigin;
}
}
/*