using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class CPoint
{
double x;
double y;
public CPoint(){} //必须的,不然 public CLine(double ll)出问题
public CPoint(double x,double y)
{
this.x=x;
this.y=y;
}
public double getx()
{return x;}
public double gety()
{return y;}
}
class CLine:CPoint
{
double l; //两点间线段的长度
public CLine() { }
public CLine(CPoint a, CPoint b)
{
l = distance(a,b);
}
public double distance(CPoint a,CPoint b)
{
l = Math.Sqrt(Math.Pow(a.getx() - b.getx(), 2) + Math.Pow(a.gety() - b.gety(), 2));
return l;
}
public double getl()
{ return l; }
}
class CRect:CLine
{
double a;
double b;
public CRect(double a,double b)
{
this.a=a;
this.b=b;
}
public double CC()
{
return 2*(a+b);
}
public double BB()
{
return a*b;
}
}
class program
{
static void Main(string []args)
{
CPoint a=new CPoint(1,1);
CPoint b=new CPoint(4,1);
CPoint c = new CPoint(4,5);
CLine m = new CLine(a,b);
CLine mm = new CLine(b,c);
Console.WriteLine("the distance of a and b is {0}", m.distance(a,b));
CRect r = new CRect(m.getl(),mm.getl());
Console.WriteLine("the c is {0},the s is {1} ",r.BB(),r.CC());
Console.ReadKey();
}
}
}