📄 testcolor.java
字号:
interface Colorable{
public abstract String howToColor();
}
abstract class GeometricObject
{
private String color="white";
private boolean fill;
protected GeometricObject()
{
}
protected GeometricObject(String color,boolean fill)
{this.color=color;
this.fill=fill;
}
public void setColor(String c)
{ this.color=c;
}
public String getColor()
{return color;
}
public boolean isFill()
{return fill;
}
public void setFill(boolean f)
{this.fill=f;
}
}
class Square extends GeometricObject implements Colorable{
private double width;
private double height;
public Square(){
this(1.0,1.0,"white",false);
}
public Square(double width,double height,String color,boolean filled){
super(color, filled);
this.width=width;
this.height=height;
}
public double getWidth(){
return width;
}
public void setWidth(double width){
this.width=width;
}
public double getHeight(){
return height;
}
public void setHeight(double height){
this.height=height;
}
public String howToColor(){
return "color it red";
}
}
class Circle extends GeometricObject{
private double radius;
public Circle(){
this(1.0,"white,false);
}
public Circle(double radius,String color,boolean filled){
super(color,filled);
this.radius=radius;
public double getRadius(){
return radius;
}
public void setRadius(double radius){
this.radius=radius;
}
public String toString() {
return "[Circle] radius = " + radius;
}
public String howToColor(){
return "color it red";
}
}
public class TestGeometricObject{
public static void main(String[] args){
GeometricObject object;
for(int i=0;i<object.length;i++){
System.out.println(
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -