public static void Main(string[] args) { Point point = new Point(5, 7); Console.WriteLine("点的坐标为{0}", point.ToString()); Circle circle = new Circle(point, 2.5); Console.WriteLine(circle.ToString()); Console.WriteLine("圆周长为{0},面积为{1}", circle.Perimeter(), circle.Area()); Cylinder cylinder = new Cylinder(point, 3, 6); Console.WriteLine(cylinder.ToString()); Console.WriteLine("圆柱体面积为{0},体积为{1}", cylinder.Area(), cylinder.Volume()); Point point1 = new Point(0, 0); Point point2 = new Point(0, 2); Point point3 = new Point(3, 0); Triangle triangle = new Triangle(point1, point2, point3); Console.WriteLine(triangle.ToString()); Console.WriteLine("三角形周长为{0},面积为{1}", triangle.Perimeter(), triangle.Area()); string s1 = triangle.IsEquicrural() ? "是" : "不是"; string s2 = triangle.IsEquilateral() ? "是" : "不是"; Console.WriteLine("三角形" + s1 + "等腰三角形," + s2 + "等边三角形"); Point point4 = new Point(3, 4); Trapaezoid trapaezoid = new Trapaezoid(point1, point2, point4, point3); Console.WriteLine(trapaezoid.ToString()); Console.WriteLine("梯形周长为{0},面积为{1},高为{2}", trapaezoid.Perimeter(), trapaezoid.Area(), trapaezoid.H); Console.WriteLine(trapaezoid.WhichParallel()); Point point5 = new Point(3, 2); Parallelogram parallelogram = new Parallelogram(point1, point2, point5, point3); Console.WriteLine(parallelogram.ToString()); Console.WriteLine("平行四边形周长为{0},面积为{1},两个高为{2},{3}", parallelogram.Perimeter(), parallelogram.Area(), parallelogram.H1, parallelogram.H2); Point point6 = new Point(1, 0); Point point7 = new Point(0, 5); Point point8 = new Point(1, 10); Point point9 = new Point(2, 5); Rhombus rhombus = new Rhombus(point6, point7, point8, point9); Console.WriteLine(rhombus.ToString()); Console.WriteLine("菱形周长为{0},面积为{1},两个高为{2},{3}", rhombus.Perimeter(), rhombus.Area(), rhombus.H1, rhombus.H2); Rectangle rectangle = new Rectangle(point1, point2, point5, point3); Console.WriteLine(rectangle.ToString()); Console.WriteLine("长方形周长为{0},面积为{1}", rectangle.Perimeter(), rectangle.Area()); Point point10 = new Point(2, 2); Point point11 = new Point(2, 0); Quadrate quadrate = new Quadrate(point1, point2, point10, point11); Console.WriteLine(quadrate.ToString()); Console.WriteLine("正方形周长为{0},面积为{1}", quadrate.Perimeter(), quadrate.Area()); Console.ReadLine(); }
public static void Main(string[] args) { double perimeter; //周长 double area; //面积 double volume; //体积 //圆类 Circle circle = new Circle(37, 43, 2.5); Console.WriteLine(circle.ToString()); perimeter = circle.CircumFerence(); area = circle.Area(); Console.WriteLine("该圆的周长是:{0}", perimeter); Console.WriteLine("该圆的面积是:{0}", area); circle.X = 20; circle.Y = 20; Console.WriteLine("该圆的新圆心坐标是:{0},{1}", circle.X, circle.Y); Console.WriteLine(); //圆柱体 double high = 10; Cylinder cylinder = new Cylinder(circle, high); Console.WriteLine(cylinder.ToString()); area = cylinder.Area(); volume = cylinder.Volume(); Console.WriteLine("该圆柱体的面积是:{0}", area); Console.WriteLine("该圆柱体的体积是:{0}", volume); Console.WriteLine(); //三角形 Point point1 = new Point(1, 1); Point point2 = new Point(4, 5); Point point3 = new Point(3, 8); Line line1 = new Line(point1, point2); Line line2 = new Line(point2, point3); Line line3 = new Line(point1, point3); Triangle triangle1 = new Triangle(point1, point2, point3); Console.WriteLine(triangle1.ToString()); Triangle triangle2 = new Triangle(line1, line2, line3); perimeter = triangle2.Perimeter(); area = triangle2.Area(); Console.WriteLine("该三角形的周长是:{0}", perimeter); Console.WriteLine("该三角形的面积是:{0}", area); if (triangle2.IsEquicrural()) { Console.WriteLine("该三角形是一个等腰三角形。"); if (triangle2.IsEquilateral()) { Console.WriteLine("该三角形是一个等边三角形。"); } } else { Console.WriteLine("该三角形不是等腰三角形。"); } Console.WriteLine(); //四边形 Point point4 = new Point(7, 3); Line line4 = new Line(point1, point4); Line line5 = new Line(point3, point4); Quadrilateral quadrilateral1 = new Quadrilateral(point1, point2, point3, point4); Console.WriteLine(quadrilateral1.ToString()); Quadrilateral quadrilateral2 = new Quadrilateral(line1, line2, line4, line5); perimeter = quadrilateral2.Perimeter(); area = quadrilateral2.Area(); Console.WriteLine("该四边形的周长是:{0}", perimeter); Console.WriteLine("该四边形的面积是:{0}", area); Console.WriteLine(); //梯形 Point point5 = new Point(2, 1); Point point6 = new Point(9, 1); Point point7 = new Point(7, 4); Point point8 = new Point(4, 4); Line line6 = new Line(point5, point6); Line line7 = new Line(point6, point7); Line line8 = new Line(point7, point8); Line line9 = new Line(point8, point5); Trapaezoid trapaezoid1 = new Trapaezoid(point5, point6, point7, point8); Trapaezoid trapaezoid2 = new Trapaezoid(line6, line7, line8, line9); Console.WriteLine(trapaezoid2.ToString()); perimeter = trapaezoid2.Perimeter(); area = trapaezoid2.Area(); Console.WriteLine("该梯形的周长是:{0}", perimeter); Console.WriteLine("该梯形的面积是:{0}", area); if (trapaezoid2.IsIsosceles()) { Console.WriteLine("这是一个等腰梯形。"); } Console.WriteLine(); //平行四边形 Parallelogram parallelogram1 = new Parallelogram(point1, point2, point3, point4); Console.WriteLine(parallelogram1.ToString()); Point point9 = new Point(5, 2); Point point10 = new Point(7, 5); Line line10 = new Line(point5, point9); Line line11 = new Line(point9, point10); Line line12 = new Line(point10, point8); Parallelogram parallelogram2 = new Parallelogram(point5, point9, point10, point8); Console.WriteLine(parallelogram2.ToString()); Parallelogram parallelogram3 = new Parallelogram(line10, line11, line12, line9); perimeter = parallelogram3.Perimeter(); area = parallelogram3.Area(); Console.WriteLine("该平形四边形的周长是:{0}", perimeter); Console.WriteLine("该平行四边形的面积是:{0}", area); Console.WriteLine(); //长方形 Rectangle rectangle1 = new Rectangle(line10, line11, line12, line9); Console.WriteLine(rectangle1.ToString()); Point point13 = new Point(1, 5); Point point14 = new Point(9, 5); Line line13 = new Line(point1, point6); Line line14 = new Line(point6, point14); Line line15 = new Line(point14, point13); Line line16 = new Line(point13, point1); Rectangle rectangle2 = new Rectangle(line13, line14, line15, line16); Console.WriteLine(rectangle2.ToString()); perimeter = rectangle2.Perimeter(); area = rectangle2.Area(); Console.WriteLine("该长方形的周长是:{0}", perimeter); Console.WriteLine("该长方形的面积是:{0}", area); Console.WriteLine(); //菱形 Point point15 = new Point(7, 6); Point point16 = new Point(4, 8); Point point17 = new Point(1, 6); Line line17 = new Line(point8, point15); Line line18 = new Line(point15, point16); Line line19 = new Line(point16, point17); Line line20 = new Line(point17, point8); Rhombus rhombus = new Rhombus(line17, line18, line19, line20); Console.WriteLine(rhombus.ToString()); perimeter = rhombus.Perimeter(); area = rhombus.Area(); Console.WriteLine("该菱形的周长是:{0}", perimeter); Console.WriteLine("该菱形的面积是:{0}", area); Console.WriteLine(); //正方形 Point point18 = new Point(2, 6); Point point19 = new Point(6, 6); Line line21 = new Line(point8, point19); Line line22 = new Line(point19, point16); Line line23 = new Line(point16, point18); Line line24 = new Line(point18, point8); Quadrate quadrate = new Quadrate(line21, line22, line23, line24); Console.WriteLine(quadrate.ToString()); perimeter = quadrate.Perimeter(); area = quadrate.Area(); Console.WriteLine("该正方形的周长是:{0}", perimeter); Console.WriteLine("该正方形的面积是:{0}", area); Console.WriteLine(); }
public static void Main(string[] args) { Circle circle = new Circle(37, 43, 2.5); Console.WriteLine("该圆的" + circle.ToString()); circle.X = 20; circle.Y = 20; Console.WriteLine("该圆的" + circle.ToString()); Console.WriteLine("-------------------------------------------------"); Cylinder cylinder = new Cylinder(32, 34, 4.5, 8); Console.WriteLine(cylinder.ToString()); Console.WriteLine("该圆柱体的底面积是:" + cylinder.Area()); Console.WriteLine("该圆柱体的体积是:" + cylinder.Volume()); Console.WriteLine("-------------------------------------------------"); Point p1 = new Point(3, 5); Point p2 = new Point(7, 5); Point p3 = new Point(5, 0); Triangle triangle = new Triangle(p1, p2, p3); Console.WriteLine(triangle.ToString()); Console.WriteLine("该三角形的周长是:" + triangle.Perimeter()); Console.WriteLine("该三角形的面积是:" + triangle.Area()); Console.WriteLine("-------------------------------------------------"); Point p4 = new Point(1, 0); Quadrilateral quadrilateral = new Quadrilateral(p4, p1, p2, p3); Console.WriteLine("该四边形的" + quadrilateral.ToString()); Console.WriteLine("该四边形的周长是:" + quadrilateral.Perimeter()); Console.WriteLine("该四边形的面积是:" + quadrilateral.Area()); Console.WriteLine("-------------------------------------------------"); Point p5 = new Point(9, 0); Trapaezoid trapaezoid = new Trapaezoid(p4, p1, p2, p5); Console.WriteLine("该梯形的" + trapaezoid.ToString()); Console.WriteLine("该梯形的周长是:" + trapaezoid.Perimeter()); Console.WriteLine("该梯形的高是:" + trapaezoid.GetHeight()); Console.WriteLine("该梯形的面积是:" + trapaezoid.Area()); Console.WriteLine("-------------------------------------------------"); Parallelogram parallelogram = new Parallelogram(p3, p1, p2, p5); Console.WriteLine("该平行四边形的" + parallelogram.ToString()); Console.WriteLine("该平行四边形的周长是:" + parallelogram.Perimeter()); Console.WriteLine("该平行四边形的高是:" + parallelogram.GetHeight()); Console.WriteLine("该平行四边形的面积是:" + parallelogram.Area()); Console.WriteLine("-------------------------------------------------"); Point p6 = new Point(5, 10); Rhombus rhombus = new Rhombus(p1, p6, p2, p3); Console.WriteLine("该菱形的" + rhombus.ToString()); Console.WriteLine("该菱形的周长是:" + rhombus.Perimeter()); Console.WriteLine("该菱形的面积是:" + rhombus.Area()); Console.WriteLine("-------------------------------------------------"); Point p7 = new Point(3, 10); Point p8 = new Point(7, 10); Quadrate quadrate = new Quadrate(p1, p7, p8, p2); Console.WriteLine("该正方形的" + quadrate.ToString()); Console.WriteLine("该正方形的周长是:" + quadrate.Perimeter()); Console.WriteLine("该正方形的面积是:" + quadrate.Area()); Console.WriteLine("-------------------------------------------------"); Point p9 = new Point(3, 0); Point p10 = new Point(7, 0); Rectangle rectangle = new Rectangle(p9, p7, p8, p10); Console.WriteLine("该长方形的" + rectangle.ToString()); Console.WriteLine("该长方形的周长是:" + rectangle.Perimeter()); Console.WriteLine("该长方形的面积是:" + rectangle.Area()); Console.WriteLine("-------------------------------------------------"); Console.ReadLine(); }