日期:2014-05-20 浏览次数:20741 次
public class GeometricObject {
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
public GeometricObject(){
dateCreated = new java.util.Date();
}
public String getColor(){
return color;
}
public void setColor(String color){
this.color = color;
}
public boolean isFilled(){
return filled;
}
public void setFilled(boolean filled){
this.filled = filled;
}
public java.util.Date getDateCreated(){
return dateCreated;
}
public String toString(){
return "created on" + dateCreated + "\ncolor:" + color + "and filled:" + filled;
}
}
public class TextTriangle{
public static void main(String[] ags){
Triangle a=new Triangle(1,1.5,1);
GeometricObject b=new GeometricObject();
System.out.println(a.getArea());
System.out.println(a.getPerimeter());
System.out.println(b.getColor());
System.out.println(b.isFilled());
}
}
b.setColor("yellow");
b.setFilled(true);
System.out.println(a.getArea());
System.out.println(a.getPerimeter());
b.setColor("yellow");//加在这里试试。
b.setFilled(true);
System.out.println(b.getColor());
System.out.println(b.isFilled());