Comparable接口 比较圆形跟长方形面积

Comparable接口 比较圆形和长方形面积
三个类:一个 Cricle        Rectangle       Geometric  还一个主方法 Main  
Cricle        
--------------------------------------

 class  P_372_Cricle  extends P_372_Geometric implements Comparable
{
private double Radius;

public P_372_Cricle()
{

}
 
public P_372_Cricle(double radius)
{
  this.Radius = radius;
}

public P_372_Cricle(String color , boolean fillde , double radius)
{
super(color , fillde);
this.Radius = radius;
}

public void setRadius(double radius)
{
this.Radius = radius;
}

public double getRadius()
{
return this.Radius;


public double getdiameter()
{
return 2 * getRadius();
}

public   double getArea()
{
return this.getRadius() * this.getRadius() * Math.PI;
}

public  double getPerimeter()
{
return this.getRadius() * 2 * Math.PI;
}

@Override
public int compareTo(Object o)
{
  if(this.getArea() > ((P_372_Cricle)o).getArea())
return 1;
else if(this.getArea() < ((P_372_Cricle)o).getArea())
return -1;
else
return 0;
}

public String toString()
{
return "圆的面积是:" + getArea() + "圆形面积大";
}
}

-------Rectangle       

class P_372_Rectangle extends P_372_Geometric implements Comparable
{
private double weigh;
private double heigh;

public P_372_Rectangle()
{

}

public P_372_Rectangle(double weigh , double heigh)
{
this.weigh = weigh;
this.heigh = heigh;
}

public P_372_Rectangle(double weigh , double heigh , String color , boolean filled)
{
super(color, filled);
this.weigh = weigh;
this.heigh = heigh; 
}

public double getWight()
{
return this.weigh;
}

public void setWight(double wight)
{
this.weigh = wight;
}

public double getHeigh()
{
return this.heigh;
}

public void setHight(double heigh)
{
this.heigh =heigh;
}
 
public  double getArea()
{
return this.getHeigh() * this.getWight();
}
 
public  double getPerimeter()
{
return (this.getHeigh() + this.getWight()) * 2;
}

public String toString()
{
return "正方形的面积是:" + getArea() + "正方形面积大";
}
@Override
public int compareTo(Object o)
{

P_372_Rectangle  aa = (P_372_Rectangle)o;
if(this.getArea() > aa.getArea())
return 1;
else if(this.getArea() < aa.getArea())
return -1;
else
 return 0;
}
}
-------Geometric  
import java.util.Date;


 public  abstract  class P_372_Geometric 
{
private String color;
private boolean fillde;
private Date dateTime;

public P_372_Geometric()
{
dateTime = new Date();
}

public P_372_Geometric(String color , boolean fillde)
{
this.color = color;
this.fillde = fillde;
}

public String getColor()
{
return this.color;
}

public void setColor(String color)
{
this.color = color;
}

public boolean isFilled()
{
return this.fillde;
}

public void setFillde(boolean fillde)
{
this.fillde = fillde;
}

public Date getDateCreatTime()
{
return this.dateTime;
}

public String toString()
{
return "The color is " + this.getColor() + "  and the fillde is " + isFilled();
}
 
public abstract double getArea();
public abstract double getPerimeter();
}
-----------------------P_372_Main
public class P_372_Main  
{
public static void main(String[] args)
{
P_372_Cricle cric = new P_372_Cricle(3);
P_372_Rectangle rec = new P_372_Rectangle(2,4);