using System;
namespace test
{
internal class Program
{
static void Main(string[] args)
{
CArea cArea = new CArea(3,4,5,6,7,8);
Console.WriteLine(cArea.GetArea());
Console.ReadKey();
}
}
public class CArea
{
private double aa, bb, cc, width, height, radius;
public CArea(double a,double b,double c,double w,double h, double r)
{
aa = a;
bb = b;
cc = c;
width = w;
height = h;
radius = r;
}
public double GetArea()
{
CTriangle cTriangle=new CTriangle(aa,bb,cc);
CRect cRect = new CRect(width,height);
CCircle cCircle = new CCircle(radius);
return cTriangle.GetData()+cRect.GetData()+cCircle.GetData();
}
}
public interface Ishape
{
double Area();
double GetData();
}
public class CTriangle : Ishape
{
private double aa,bb,cc;
public CTriangle(double a, double b, double c)
{
aa = a;bb = b;cc = c;
}
public double Area()
{
double p = (aa + bb + cc) / 2.0;
double area;
area = Math.Sqrt(p*(p-aa)*(p-bb)*(p-cc));
return area;
}
public double GetData()
{
return Area();
}
}
public class CRect : Ishape
{
private double width,height;
public CRect(double w, double h)
{
width = w;height = h;
}
public double Area()
{
return width * height;
}
public double GetData()
{
return Area();
}
}
public class CCircle : Ishape
{
private double radius;
public CCircle(double r)
{
radius = r;
}
public double Area()
{
return Math.PI * radius * radius;
}
public double GetData()
{
return Area();
}
}
}
|