📄 rectangle.java
字号:
/*
* 创建日期 2006-1-31
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package ch6;
public class Rectangle {
private int x ;
private int y ;
private int width ;
private int height ;
public Rectangle(int myx, int myy,int mywidth,int myheight)
{
x=myx;
y=myy;
width=mywidth;
height=myheight;
}
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 int getArea()
{
return width*height;
}
public void offset(int ax , int ay ){
x = x + ax;
y = y + ay;
}
public void Inflate(int inwidth,int inheight)
{
x=x-inwidth;
y=y-inheight;
height=height+2*inheight;
width=width+2*inwidth;
}
public String print()
{ String str;
str="X="+x+", Y="+y+"\n";
str+="Width="+width+" Height="+height+"\n";
str+=" Area="+ getArea()+"\n";
return str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -