rectangle.java

来自「JAVA 工作指南 可以说是程序员必备的东西哦」· Java 代码 · 共 49 行

JAVA
49
字号
public class Rectangle {    /** The width of this rectangle. */    public int width;    /** The height of this rectangle. */    public int height;    /** The origin (lower-left corner) of this rectangle. */    public Point origin;    /**     * Creates a rectangle with the specified size.     * The origin is (0, 0).     * @param w width of the rectangle     * @param h height of the rectangle     */    public Rectangle(int w, int h) {	this(new Point(0, 0), w, h);    }    /**     * Creates a rectangle with the specified origin and     * size.     * @param p origin of the rectangle     * @param w width of the rectangle     * @param h height of the rectangle     */    public Rectangle(Point p, int w, int h) {	origin = p;	width = w;	height = h;    }    /**     * Moves the rectangle to the specified origin.     */    public void move(int x, int y) {	origin.x = x;	origin.y = y;    }    /**     * Returns the computed area of the rectangle.     */    public int area() {	return width * height;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?