static void Main() { Console.Write("Enter Radius of a circle: "); double a = int.Parse(Console.ReadLine()); Circle circle = new Circle(a); Console.WriteLine("Circle:"); circle.CalculateArea(); Console.WriteLine(); Console.Write("Enter Width of a Rectangle: "); double b = int.Parse(Console.ReadLine()); Console.Write("Enter Height of a Rectangle: "); double c = int.Parse(Console.ReadLine()); Rectangle rect = new Rectangle(b, c); Console.WriteLine("Rectangle:"); rect.CalculateArea(); rect.CalculatePerimeter(); Console.WriteLine(); Console.Write("Enter Width of a Rhombus: "); double d = int.Parse(Console.ReadLine()); Console.Write("Enter Height of a Rhombus: "); double e = int.Parse(Console.ReadLine()); Rhombus rhombus = new Rhombus(d, e); Console.WriteLine("Rhombus:"); rhombus.CalculateArea(); rhombus.CalculatePerimeter(); Console.WriteLine(); }
public static void Main(string[] args) { var triangle = new Triangle(new List <Point>() { new Point(0, 0), new Point(5, 5), new Point(0, 5) }); var rectangle = new Rectangle(new List <Point>() { new Point(0, 0), new Point(0, 5), new Point(5, 5), new Point(5, 0) }); var rhombus = new Rhombus(new List <Point> { new Point(0, 1), new Point(2, 0), new Point(4, 1), new Point(2, 2) }); var areaVisitor = new GetAreaVisitor(); triangle.Accept(areaVisitor); Console.WriteLine(areaVisitor.Result); rectangle.Accept(areaVisitor); Console.WriteLine(areaVisitor.Result); rhombus.Accept(areaVisitor); Console.WriteLine(areaVisitor.Result); Console.WriteLine(); var drawVisitor = new DrawingVisitor(new Point(5, 5)); triangle.Accept(drawVisitor); rectangle.Accept(drawVisitor); rhombus.Accept(drawVisitor); var polygonLoveVisitor = new PolygonLoveVisitor(); triangle.Accept(polygonLoveVisitor); rectangle.Accept(polygonLoveVisitor); rhombus.Accept(polygonLoveVisitor); }
private static List <EdgeAggregator> InstantiateToTheorem(Rhombus rhombus, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // For hypergraph List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(original); // Instantiate this rhombus diagonals ONLY if the original figure has the diagonals drawn. if (rhombus.TopLeftDiagonalIsValid()) { AngleBisector ab1 = new AngleBisector(rhombus.topLeftAngle, rhombus.topLeftBottomRightDiagonal); AngleBisector ab2 = new AngleBisector(rhombus.bottomRightAngle, rhombus.topLeftBottomRightDiagonal); newGrounded.Add(new EdgeAggregator(antecedent, ab1, annotation)); newGrounded.Add(new EdgeAggregator(antecedent, ab2, annotation)); } if (rhombus.BottomRightDiagonalIsValid()) { AngleBisector ab1 = new AngleBisector(rhombus.topRightAngle, rhombus.bottomLeftTopRightDiagonal); AngleBisector ab2 = new AngleBisector(rhombus.bottomLeftAngle, rhombus.bottomLeftTopRightDiagonal); newGrounded.Add(new EdgeAggregator(antecedent, ab1, annotation)); newGrounded.Add(new EdgeAggregator(antecedent, ab2, annotation)); } return(newGrounded); }
public void AreaPerimetrRhombus() { Rhombus rhombus = new Rhombus(8); Assert.AreEqual(48, rhombus.Area()); Assert.AreEqual(32, rhombus.Perimetr()); }
static void Main(string[] args) { Console.Write("\n\n###### Program starts ######\n\n"); Rhombus rhombus = new Rhombus(); string newChar; int newMaxWidth; header(); Console.Write("\nInput a Character value => "); newChar = Console.ReadLine(); Console.Write("\nInput the Rhombus's maximum width value => "); newMaxWidth = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n\n"); rhombus.setChar(newChar[0]); rhombus.setMaxWidth(newMaxWidth); rhombus.drawRhombus(); Console.Write("\n\n###### Program ends ######\n\n"); Console.ReadLine(); // Pause programs before exit }
// A __________ B // | | // | | // | | // D |__________| C // // Rhombus(A, B, C, D) -> AngleBisector(Angle(A, B, C), Segment(B, D)) // AngleBisector(Angle(A, D, C), Segment(B, D)) // AngleBisector(Angle(B, A, D), Segment(A, C)) // AngleBisector(Angle(B, C, D), Segment(A, C)) // public static List <EdgeAggregator> Instantiate(GroundedClause clause) { annotation.active = EngineUIBridge.JustificationSwitch.DIAGONALS_OF_RHOMBUS_BISECT_ANGLES_OF_RHOMBUS; List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is Rhombus) { Rhombus rhombus = clause as Rhombus; newGrounded.AddRange(InstantiateToTheorem(rhombus, rhombus)); } else if (clause is Strengthened) { Strengthened streng = clause as Strengthened; if (!(streng.strengthened is Rhombus)) { return(newGrounded); } newGrounded.AddRange(InstantiateToTheorem(streng.strengthened as Rhombus, streng)); } return(newGrounded); }
private static List <EdgeAggregator> InstantiateToSquare(Rhombus rhombus, RightAngle ra, GroundedClause originalRhom, GroundedClause originalRightAngle) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // Does this right angle apply to this quadrilateral? if (!rhombus.HasAngle(ra)) { return(newGrounded); } // // Create the new Square object // Strengthened newSquare = new Strengthened(rhombus, new Square(rhombus)); // For hypergraph List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(originalRhom); antecedent.Add(originalRightAngle); newGrounded.Add(new EdgeAggregator(antecedent, newSquare, annotation)); return(newGrounded); }
public void Visit(Rhombus rhombus) { var points = rhombus.Vertices.Select(x => new Point(x.X + shiftVector.X, x.Y + shiftVector.Y)).ToList(); points.ForEach(x => Console.WriteLine(x)); Console.WriteLine(); }
static void Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; Console.WriteLine("Мулік Рустам ІС-93\n_______________________________________\n"); double[] A = { 6, 3 }; double[] B = { 9, 4 }; double[] C = { 10, 7 }; double[] D = { 7, 6 }; Rhombus romb = new Rhombus(A, B, C, D); Circle krug = new Circle(5); Console.WriteLine("Координати вершин ромба:"); Console.WriteLine("A(" + $"{A[0]}, {A[1]}" + ")"); Console.WriteLine("B(" + $"{B[0]}, {B[1]}" + ")"); Console.WriteLine("C(" + $"{C[0]}, {C[1]}" + ")"); Console.WriteLine("D(" + $"{D[0]}, {D[1]}" + ")"); Console.WriteLine("Радіус кола = " + krug.Radius + "\n"); Console.WriteLine("Площа ромба = " + romb.S().ToString("F3") + "\n"); Console.WriteLine("Периметр ромба = " + romb.P().ToString("F3") + "\n"); Console.WriteLine("Площа круга = " + krug.S().ToString("F3") + "\n"); Console.WriteLine("Довжина кола = " + krug.P().ToString("F3") + "\n"); Console.ReadKey(); }
private void canvas_Paint(object sender, PaintEventArgs e) { Graphics gObject = canvas.CreateGraphics(); Triangle triangle1 = new Triangle(500, 95, gObject, Color.Red, 8); Triangle triangle2 = new Triangle(100, 350, gObject, Color.Red, 8); Circle circle1 = new Circle(450, 225, gObject, Color.Red, 8); Square square1 = new Square(50, 50, gObject, Color.Red, 8); Rhombus rhombus1 = new Rhombus(630, 250, gObject, Color.Red, 8); Circle circle2 = new Circle(630, 380, gObject, Color.Red, 8); Line line1 = new Line(110, 75, 445, 235, gObject, Color.Red, 8, LineCap.ArrowAnchor, LineCap.ArrowAnchor); Line line2 = new Line(550, 105, 480, 215, gObject, Color.Red, 8, LineCap.ArrowAnchor, null, DashStyle.Dot); Line line3 = new Line(80, 110, 120, 320, gObject, Color.Red, 8, LineCap.ArrowAnchor, LineCap.ArrowAnchor, DashStyle.Dash); Line line4 = new Line(500, 245, 600, 250, gObject, Color.Red, 8, LineCap.ArrowAnchor, null, DashStyle.Dot); Line line5 = new Line(210, 320, 615, 260, gObject, Color.Red, 8, LineCap.ArrowAnchor, null, DashStyle.DashDotDot); IDraw[] figuresAndLines = new IDraw[] { triangle1, triangle2, circle1, square1, rhombus1, circle2, line1, line2, line3, line4, line5 }; foreach (var element in figuresAndLines) { element.Draw(); } }
public void Create_NewUnkownFigure_Test() { Figure figure = new Figure(); IFigure rhombus = new Rhombus(1, 2); Assert.AreEqual(2, figure.GetArea(rhombus)); }
public void TestForArea1() { var rhombus = new Rhombus(2, 5); var result = rhombus.Area(); var expected = 10; Assert.AreEqual(expected, result); }
public void TestForPerimeter1() { var rhombus = new Rhombus(2, 5); var result = rhombus.Perimeter(); var expected = 8; Assert.AreEqual(expected, result); }
public void RhombusAreaTest() { Rhombus square3 = new Rhombus(); Rhombus.side = 3.0; Rhombus.altitude = 4.0; Assert.IsTrue(square3.areaEquasion() == 12); }
private void CreateRhombus_Click(object sender, RoutedEventArgs e) { Rhombus rhomb = new Rhombus(); rhomb.Launch(Rhomb_Txb.Text); list_txb.Text = "Create object: " + rhomb.Nameobject.Name; count++; Console_Txb.Text = "Count of object: " + count.ToString(); }
public void RhombusMeasurement() { var rhombus = new Rhombus(); rhombus.Height = 3; rhombus.Side = 2; Assert.AreEqual(rhombus.Perimeter, 8.0); Assert.AreEqual(rhombus.GetArea(), 6.0); }
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(); }
static void Main() { Rectangle s = new Rectangle(4.5, 7.2, "Rectangle"); Circle c = new Circle(3.1, "CIrcle"); Rhombus r = new Rhombus(3.27, 5.4, 3.7, "Rhombus"); Triangle t = new Triangle(6.1, 8.3, 4.9, 3.57, "Triangle"); s.GetInfo(); c.GetInfo(); r.GetInfo(); t.GetInfo(); }
static void Main(string[] args) { //Side side1 = new Side(new Point(1, 1), new Point(6, 7)); //Side side2 = new Side(new Point(6, 7), new Point(10, 20)); //Console.WriteLine($"{side1.ComputeAngleTo(side2)}"); //Rhombus rhombus = new Rhombus(new Point(1, 1), new Point(3, 4), new Point(6, 7), new Point(10, 20)); //Rhombus rhombus = new Rhombus(new Point(0, 0), new Point(-3, -12), new Point(0, -24), new Point(3, -12)); //Rhombus rhombus = new Rhombus(new Point(0, 0), new Point(-3, -12), new Point(0, -25), new Point(3, -12)); Rhombus rhombus = new Rhombus(new Point(1, 1), new Point(1, 4), new Point(4, 4), new Point(4, 1)); Console.WriteLine($"{rhombus.IsValid()}"); }
public void Visit(Rhombus rhombus) { var a = rhombus.Vertices[0]; var b = rhombus.Vertices[1]; var c = rhombus.Vertices[2]; var d = rhombus.Vertices[3]; var ac = GetDistance(a, c); var bd = GetDistance(b, d); var square = 1.0 / 2 * ac * bd; Result = square; }
static void Main(string[] args) { /*вычисление углов в градусах * вычисление длин диагоналей * вычисление длин сторон * вычисление периметра * вычисление площади */ double a, b, c, d, d1, d2; Console.WriteLine("\n\nPARALLELOGRAM:"); Parallelogram parallelogram = new Parallelogram(-3, 1, -4, 4, 0, 4, 1, 1); parallelogram.DisplayPoints(); parallelogram.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); parallelogram.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); parallelogram.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {parallelogram.GetPerimeter()}"); Console.WriteLine($"Area = {parallelogram.GetArea()}"); Console.WriteLine("\n\nRHOMBUS:"); Rhombus rhombus = new Rhombus(-1, -2, 0, 0, 1, -2, 0, -3); rhombus.DisplayPoints(); rhombus.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); rhombus.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); rhombus.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {rhombus.GetPerimeter()}"); Console.WriteLine($"Area = {rhombus.GetArea()}"); Console.WriteLine("\n\nSQUARE:"); Square sqaure = new Square(1, 1, 1, 3, 3, 3, 3, 1); sqaure.DisplayPoints(); sqaure.GetAngles(out a, out b, out c, out d); Console.WriteLine($"ANGLES:\nA = {a}\nB = {b}\nC = {c}\nD = {d}"); sqaure.GetDiagonalsLength(out d1, out d2); Console.WriteLine($"\nDIAGONALS:\nd1 = {d1}\nd2 = {d2}"); sqaure.GetSides(out a, out b, out c, out d); Console.WriteLine($"\nSIDES:\na = {a}\nb = {b}\nc = {c}\nd = {d}"); Console.WriteLine($"Perimeter = {sqaure.GetPerimeter()}"); Console.WriteLine($"Area = {sqaure.GetArea()}");; Console.ReadKey(); }
static void Main(string[] args) { Circle circle = new Circle(5); Rhombus rhombus = new Rhombus(5, 2); Rectangle rectangle = new Rectangle(2, 10); IShape[] shapes = { circle,rhombus,rectangle}; foreach (var shape in shapes) { Console.WriteLine("Area: {0}",shape.CalculateArea()); Console.WriteLine("Perimeter: {0}", shape.CalculatePerimeter()); } }
public static void Main(string[] args) { //注意所有几何体的点按照逆时针输入 Circle circle = new Circle(0, 0, 1); Console.WriteLine("半径为1的圆的面积为:" + circle.Area().ToString()); Console.WriteLine("半径为1的圆的周长为:" + circle.CircumFerence().ToString()); Cylinder cylinder = new Cylinder(); cylinder.R = 1; cylinder.h = 1; Console.WriteLine("半径为1,高为1的圆柱体的表面积为:" + cylinder.Area().ToString()); Console.WriteLine("半径为1,高为1的圆柱体的体积为:" + cylinder.GetV().ToString()); Quadrilateral quadrilateral = new Quadrilateral(1, 2, 2, 3, 3, 4, 1, 4); Console.WriteLine("普通四边形的周长:" + quadrilateral.Perimeter().ToString()); Console.WriteLine("普通四边形的面积:" + quadrilateral.Area().ToString()); Trapaezoid trapaezoid = new Trapaezoid(0, 0, 2, 0, 2, 1, 1, 1); Console.WriteLine("梯形的周长:" + trapaezoid.Perimeter().ToString()); Console.WriteLine("梯形的面积:" + trapaezoid.Area().ToString()); Parallelogram parallelogram = new Parallelogram(0, 0, 2, 0, 3, 1, 1, 1); Console.WriteLine("平行四边形的周长:" + parallelogram.Perimeter().ToString()); Console.WriteLine("平行四边形的面积:" + parallelogram.Area().ToString()); Rectangle rectangle = new Rectangle(0, 0, 2, 0, 2, 1, 0, 1); Console.WriteLine("长为2,宽为1的矩形面积为:" + rectangle.Area().ToString()); Console.WriteLine("长为2,宽为1的矩形周长为:" + rectangle.Perimeter().ToString()); Rhombus rhombus = new Rhombus(0, 0, 2, 1, 3, 3, 1, 2); Console.WriteLine("菱形的周长:" + rhombus.Perimeter().ToString()); Console.WriteLine("菱形的面积:" + rhombus.Area().ToString()); Quadrate quadrate = new Quadrate(0, 0, 1, 0, 1, 1, 0, 1); Console.WriteLine("正方形的周长:" + quadrate.Perimeter().ToString()); Console.WriteLine("正方形的面积:" + quadrate.Area().ToString()); Triangle triangle = new Triangle(new Point(0, 0), new Point(1, 0), new Point(0, 1)); Console.WriteLine("三角形的面积为: " + triangle.Area().ToString()); Console.WriteLine("三角形的周长为: " + triangle.Perimeter().ToString()); }
static void Main(string[] args) { // 5 squares var square1 = new Square(); var square2 = new Square(); var square3 = new Square(); var square4 = new Square(); var square5 = new Square(); // + 5 more squares square5.ExternalSquare(); // 3 circles var circle1 = new Circle(); var circle2 = new Circle(); var circle3 = new Circle(); // 2 triangles var triangle1 = new Triangle(); var triangle2 = new Triangle(); // 4 rhombi + 1 for each square (4 + 10) var rhombus1 = new Rhombus(); var rhombus2 = new Rhombus(); var rhombus3 = new Rhombus(); var rhombus4 = new Rhombus(); // trigger GC to prove it all works System.GC.Collect(); // Output Console.WriteLine("Here are the instances of each of the classes: "); Console.WriteLine("Square: " + InstanceTracker.GetInstance().CountInstances(typeof(Square))); Console.WriteLine("Square (alive instances): " + InstanceTracker.GetInstance().CountInstances(typeof(Square), true)); Console.WriteLine(); Console.WriteLine("Circle: " + InstanceTracker.GetInstance().CountInstances(typeof(Circle))); Console.WriteLine("Circle: (alive instances): " + InstanceTracker.GetInstance().CountInstances(typeof(Circle), true)); Console.WriteLine(); Console.WriteLine("Triangle: " + InstanceTracker.GetInstance().CountInstances(typeof(Triangle))); Console.WriteLine("Triangle (alive instances): " + InstanceTracker.GetInstance().CountInstances(typeof(Triangle), true)); Console.WriteLine(); Console.WriteLine("Rhombus: " + InstanceTracker.GetInstance().CountInstances(typeof(Rhombus))); Console.WriteLine("Rhombus (alive instances): " + InstanceTracker.GetInstance().CountInstances(typeof(Rhombus), true)); }
static void Main(string[] args) { Square square = new Square(10); Triangle triangle = new Triangle(5, 3); Paralelogram paralelogram = new Paralelogram(50, 70); Rectangle rectangle = new Rectangle(3, 8); Rhombus rhombus = new Rhombus(15, 18); CalculateArea areaCalculation = new CalculateArea(); Console.WriteLine($"Square area: {areaCalculation.CalculateGivenShapesArea(square)}"); Console.WriteLine($"Triangle area: {areaCalculation.CalculateGivenShapesArea(triangle)}"); Console.WriteLine($"Paralelogram area: {areaCalculation.CalculateGivenShapesArea(paralelogram)}"); Console.WriteLine($"Rectangle area: {areaCalculation.CalculateGivenShapesArea(rectangle)}"); Console.WriteLine($"Rhombus area: {areaCalculation.CalculateGivenShapesArea(rhombus)}"); }
public static void LocalCoordinates_Returns_Coordinates_of_Vertices_in_Original_Local_Coordinates() { Rhombus rhombus = new Rhombus(width, height); IList <CartesianCoordinate> coordinates = rhombus.LocalCoordinates(); Assert.AreEqual(width / 2, coordinates[0].X); Assert.AreEqual(0, coordinates[0].Y); Assert.AreEqual(width, coordinates[1].X); Assert.AreEqual(height / 2, coordinates[1].Y); Assert.AreEqual(width / 2, coordinates[2].X); Assert.AreEqual(height, coordinates[2].Y); Assert.AreEqual(0, coordinates[3].X); Assert.AreEqual(height / 2, coordinates[3].Y); }
static void Main(string[] args) { Console.Title = "Lab №6"; ProgramInfo(); Console.WriteLine(); const int rhombusPointsQuantity = 4; Point[] rhombusPoints = new Point[rhombusPointsQuantity]; for (int i = 0; i < rhombusPointsQuantity; i++) { EnterPoint(out rhombusPoints[i], i + 1); } Figure rhombus1; try // check whether entered coordinates can be coordinates of a rhombus { rhombus1 = new Rhombus(rhombusPoints); } catch (NotARhombusException) // if exception is throws, the rhombus th formed from defined(hard-coded) coordinates { Console.WriteLine("You entered not a rhombus"); Console.WriteLine("The rhombus will be created with defined coordinates: "); Console.WriteLine("(-1, 0)\n( 0, 2)\n( 1, 0)\n( 0, -2)"); Point[] definedRhombusPoints = { new Point(-1, 0), new Point(0, 2), new Point(1, 0), new Point(0, -2) }; rhombus1 = new Rhombus(definedRhombusPoints); } Console.WriteLine("The area of your rhombus is: {0:F6}", rhombus1.GetArea()); Console.WriteLine("The perimeter of your rhombus is: {0:F6}", rhombus1.GetPerimeter()); Console.WriteLine(); double radius; bool parsed; do { Console.WriteLine("Enter the radius of the circle: "); parsed = double.TryParse(Console.ReadLine().Replace('.', ','), out radius); }while (!parsed || radius <= 0); // checking whether radius is bigger than 0 Figure circle1 = new Circle(radius); Console.WriteLine("The area of your circle is: {0:F6}", circle1.GetArea()); Console.WriteLine("The perimeter of your circle is: {0:F6}", circle1.GetPerimeter()); Console.WriteLine("\nPress ENTER to quit"); Console.Read(); }
static void Main(string[] args) { Point A = new Point(0, 0); Point B = new Point(0, 8); Point C = new Point(8, 0); Point D = new Point(8, 8); try { Ellipse ellips = new Ellipse(A, B, C); Console.WriteLine(ellips); Circle circle = new Circle(A, C); Console.WriteLine(circle); Trapezium trapezium = new Trapezium(A, B, C, D); Console.WriteLine(trapezium); Triangle trianle = new Triangle(A, B, C); Console.WriteLine(trianle); Parallelogram parallelogram = new Parallelogram(A, B, C, D); Console.WriteLine(parallelogram); Rectangle rectangle = new Rectangle(A, B, C, D); Console.WriteLine(rectangle); Rhombus rhombus = new Rhombus(A, B, C, D); Console.WriteLine(rhombus); Square square = new Square(A, B, C, D); Console.WriteLine(square); } catch (ApplicationException e) { Console.WriteLine(" {0} ", e.Message); } finally { Console.WriteLine("\nBy!\n"); } Console.ReadKey(); }
private static List <EdgeAggregator> InstantiateFromRhombus(Rhombus rhombus, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // For hypergraph List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(original); // Determine the CongruentSegments : 4 Choose 2 newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.bottom), annotation)); newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.left), annotation)); newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.top, rhombus.right), annotation)); newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.bottom, rhombus.left), annotation)); newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.bottom, rhombus.right), annotation)); newGrounded.Add(new EdgeAggregator(antecedent, new GeometricCongruentSegments(rhombus.left, rhombus.right), annotation)); return(newGrounded); }
public static void Main() { Rectangle rectangle = new Rectangle(4, 6); Rhombus rhombus = new Rhombus(2, 5); Circle circle = new Circle(12); Console.WriteLine("Rectangle:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n", rectangle.CalculateArea(), rectangle.CalculatePerimeter() ); Console.WriteLine("Rhombus:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n", rhombus.CalculateArea(), rhombus.CalculatePerimeter() ); Console.WriteLine("Circle:\n\tArea: {0:F3}\n\tPerimeter: {1:F3}\n", circle.CalculateArea(), circle.CalculatePerimeter() ); }
public static void Initialization_with_Dimensions_Creates_Shape() { Rhombus rhombus = new Rhombus(width, height); Assert.AreEqual(4, rhombus.Points.Count); Assert.AreEqual(4, rhombus.Angles.Count); Assert.AreEqual(4, rhombus.Sides.Count); Assert.AreEqual(GeometryLibrary.ZeroTolerance, rhombus.Tolerance); Assert.AreEqual(5, rhombus.Centroid.X, Tolerance); Assert.AreEqual(2.5, rhombus.Centroid.Y, Tolerance); Assert.AreEqual(width / 2, rhombus.g); Assert.AreEqual(height, rhombus.q); Assert.AreEqual(width, rhombus.w); Assert.AreEqual(height / 2, rhombus.h); Assert.AreEqual(5.590169944, rhombus.a, Tolerance); Assert.AreEqual(5.590169944, rhombus.b, Tolerance); Assert.AreEqual(5, rhombus.InCenter.X, Tolerance); Assert.AreEqual(2.5, rhombus.InCenter.Y, Tolerance); Assert.AreEqual(2.236067977, rhombus.InRadius, Tolerance); }
public void RhombusTest() { SetUp(); // 1 + 5 more squares var square = new Square(); square.ExternalSquare(); // 4 rhombi + 1 for each square (4 + 6) var rhombus1 = new Rhombus(); var rhombus2 = new Rhombus(); var rhombus3 = new Rhombus(); var rhombus4 = new Rhombus(); // trigger GC System.GC.Collect(); Assert.Equal(10, InstanceTracker.GetInstance().CountInstances(typeof(Rhombus))); Assert.Equal(4, InstanceTracker.GetInstance().CountInstances(typeof(Rhombus), true)); }
static void Main() { Rectangle firstRectangle = new Rectangle(4.5, 7.3); Circle firstCircle = new Circle(4); Rhombus firstRhombus = new Rhombus(5.2, 3.75); BasicShape secondRectangle = new Rectangle(12, 3.1); BasicShape secondRhombus = new Rhombus(8, 3.1); Circle seocndCircle = new Circle(3.5); IShape[] shapes = { firstRectangle, firstCircle, firstRhombus, secondRectangle, secondRhombus, seocndCircle }; foreach (var shape in shapes) { Console.WriteLine(shape.ToString()); } }