?? testshape.java
字號:
interface shape
{
abstract void draw();
abstract void resize();
}
class point implements shape
{
private int x;
private int y;
public void draw()
{
System.out.println("the point zuobiao is("+x+","+y+")");
}
public void resize()
{
System.out.println("point turn big") ;
}
public point(int x,int y)
{
this.x=x;
this.y=y;
}
}
class line implements shape
{
private int x1;
private int y1;
private int x2;
private int y2;
public void draw()
{
System.out.println("the line first point is ("+x1+","+y1+")second point is:("+x2+","+y2+")");
}
public void resize()
{
System.out.println("line turn big");
}
public line(int a,int b,int c,int d)
{
x1=a;y1=b;x2=c;y2=d;
}
}
class circle implements shape
{
private int x;
private int y;
private int width;
private int height;
private double r;
public void draw()
{
System.out.println("the circle point zuobiao is("+x+","+y+")");
System.out.println("the circle radus:"+r);
}
public void resize()
{
System.out.println("circle turn big");
}
public circle(int a,int b,int c,int d)
{
x=a;
y=b;
width=c;
height=d;
r=(double)width/2;
}
}
class rectangle implements shape
{
private int x;
private int y;
private int width;
private int height;
public void draw()
{
System.out.println("the rectangle's left zuobiao is:("+x+","+y+")");
System.out.println("the rectangel's width and height is :("+width+","+height+")");
}
public void resize()
{
System.out.println("rectangle turn big");
}
public rectangle(int a,int b,int c,int d)
{
x=a;
y=b;
width=c;
height=d;
}
}
public class testshape
{
public static void main(String args[])
{
point p1=new point(3,5);
line p2=new line(3,4,20,30);
circle p3=new circle(10,20,20,20);
rectangle p4=new rectangle(10,5,50,30);
p1.draw();
p1.resize();
p2.draw();
p2.resize();
p3.draw();
p3.resize();
p4.draw();
p4.resize();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -