📄 rec2.java
字号:
interface Shape
{
public void getArea();
public void getCircumference();
public void noUse();
}
interface Color
{
public void getColor();
}
class Rectangle implements Shape,Color
{
private int x,y;
private double width,height;
String color;
Rectangle()
{
x=0;
y=0;
}
Rectangle(double w,double h,String c)
{
width=w;
height=h;
color=c;
}
public double getWidth()
{ return width; }
public double getHeight()
{ return height; }
public void setWidth(double width)
{
this.width=width;
}
public void setHeight(double height)
{
this.height=height;
}
public void setColor(String color)
{
this.color=color;
}
public void getArea()
{
System.out.println("The Area is "+width*height+"\n");
}
public void getCircumference()
{
System.out.println("The Circumference is "+2*(width+height)+"\n");
}
public void getColor()
{
System.out.println("The color is "+color+"\n");
}
public void noUse() {}
}
public class Rec2
{
public static void main(String[] args)
{
Rectangle r=new Rectangle(5,6,"Red");
r.getColor();
r.getArea();
r.getCircumference();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -