public class TestColor{
public static void main(String[] args){
point p= new point(3.13,6.29);
System.out.println(p.print());
colorpoint cp = new colorpoint(4.80,8.19,"green");
System.out.println(cp.print());
}
}
class point{
public double x;
public double y;
public point(double x,double y){
this.x=x;
this.y=y;}
public String print(){
return "这是一个点point:( "+x+" , "+y+")";}
}
class colorpoint extends point{
public String color="green";
public colorpoint(double x,double y,String color){
super(x,y);
this.color=color;}
public String print(){
return "这是一个有颜色的点colorpoint:( "+x+" , "+y+") , color:"+color;}
}