rectangle.java
来自「Java与面向对象程序设计实验教学讲义.复数类的实现,复数类的复杂运算,身份证号」· Java 代码 · 共 35 行
JAVA
35 行
package graphics.twoD;
public class Rectangle {
public int width = 0;
public int height = 0;
public Point origin;
// 定义了四个构造方法。
/* public Rectangle() {
origin = new Point(0, 0);
}
public Rectangle(Point p) {
origin = p;
}
public Rectangle(int w, int h) {
this(new Point(0, 0), w, h);
}*/
public Rectangle(Point p, int w, int h) {
origin = p;
width = w;
height = h;
}
// 移动矩形的方法。
public void move(int x, int y) {
origin.x = x;
origin.y = y;
}
// 计算矩形面积的方法。
public int area() {
return width * height;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?