⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rectangle.java

📁 还不错的java基本实例
💻 JAVA
字号:
/*
 * 创建日期 2006-1-29
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package ch4;
public class Rectangle {
    private int x ;
    private int y ;
    private int width ;
    private int height ;

    public  Rectangle(){
        x = 5;
        y = 10;
        width = 50;
        height = 25;
    }
    

    public void setX(int ax ){
        x = ax;
    } 
    public int getX() {
        return x;
    }

    public void setY(int ay){
        x = ay;
    }
    public int getY() {
        return y;
    }

    public void setWidth(int awidth ){
        width = awidth;
    }
    public int getWidth() {
        if (width > 0) 
            return width;
        else
            return 0;
    }

    public void setHeight(int aheight){
        height = aheight;
    }
    public int getHeight() {
        return height;
    }

    public void offset(int ax , int ay ){
        x = x + ax;
        y = y + ay;
    }

    public static void Inflate(Rectangle rec  , int inwidth , int inheight ){
        rec.x = rec.x - inwidth;
        rec.y = rec.y - inheight;
        rec.height = rec.height + 2 * inheight;
        rec.width = rec.width + 2 * inwidth;
    }
}

⌨️ 快捷键说明

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