public void Area_Test_For_Triangle_3_4_5_Returns_6() { Shapes.Triangle triangle = new Shapes.Triangle(3, 4, 5); double area; area = triangle.Area(); Assert.That(area, Is.EqualTo(6)); }
static void Main(string[] args) { Rectangle rectangleOne = new Rectangle(3, 5); Rectangle rectangleTwo = new Rectangle(4, 5); Rectangle sumOfTwoRectangle = rectangleOne + rectangleTwo; Square squareOne = new Square(5); Square squareTwo = new Square(7); Square sumOfTwoSquare = squareOne + squareTwo; Circle circleOne = new Circle(7); Circle circleTwo = new Circle(10); Circle sumOfTwoCircle = circleOne + circleTwo; Triangle triangleOne = new Triangle(8); Triangle triangleTwo = new Triangle(10); Triangle sumOfTwoTriangles = triangleOne + triangleTwo; Octagon octagonOne = new Octagon(4); Octagon octagonTwo = new Octagon(7); Octagon sumOfTwoOctagon = octagonOne + octagonTwo; Pentagon pentagonOne = new Pentagon(4); Pentagon pentagonTwo = new Pentagon(7); Pentagon sumOfTwoPentagon = pentagonOne + pentagonTwo; Console.WriteLine("Rectangle One"); rectangleOne.Area(); rectangleOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Rectangle two"); rectangleTwo.Area(); rectangleTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of Rectangle"); sumOfTwoRectangle.Area(); sumOfTwoRectangle.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Square One"); squareOne.Area(); squareOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Square Two"); squareTwo.Area(); squareTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of two Squares"); sumOfTwoSquare.Area(); sumOfTwoSquare.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Circle One"); circleOne.Area(); circleOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Circle One"); circleTwo.Area(); circleTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of two Circle"); sumOfTwoCircle.Area(); sumOfTwoCircle.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Triangle One"); triangleOne.Area(); triangleOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Triangle Two"); triangleTwo.Area(); triangleTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of two Triangle"); sumOfTwoTriangles.Area(); sumOfTwoTriangles.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Pentagon One"); pentagonOne.Area(); pentagonOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Pentagon Two"); pentagonTwo.Area(); pentagonTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of two Pentagon"); sumOfTwoPentagon.Area(); sumOfTwoPentagon.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Octagon One"); octagonOne.Area(); octagonOne.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Octagon Two"); octagonTwo.Area(); octagonTwo.Circumference(); Console.WriteLine("-----------------"); Console.WriteLine("Sum of Octagon"); sumOfTwoOctagon.Area(); sumOfTwoOctagon.Circumference(); Console.WriteLine("-----------------"); Console.ReadLine(); }
static void Main(string[] args) { bool flag = true; while (flag) { Console.WriteLine("Please select shape to process or [Q]uit:\n [C]ircle \n [R]ectangle \n [S]quare \n [T]raingle \n"); string program = (Console.ReadLine()); if (program == "q" || program == "Q") { Environment.Exit(0); } else if (program == "c" || program == "C") { Console.WriteLine("Please enter circle radius: "); double r = double.Parse(Console.ReadLine()); Circle circle = new Circle(r); Console.WriteLine("Please select output: \n [A]rea \n [P]erimeter \n [B]oth\n"); string a = (Console.ReadLine()); if (a == "a" || a == "A") { Console.WriteLine("Area of circle: " + circle.Area() + "\n"); } else if (a == "p" || a == "P") { Console.WriteLine("Perimeter of circle: " + circle.Perimeter() + "\n"); } else if (a == "b" || a == "B") { Console.WriteLine("Perimeter of circle: " + circle.Perimeter() + " \n Area of the circle: " + circle.Area() + "\n"); } } else if (program == "r" || program == "R") { Console.WriteLine("Please enter rectangle lengh: "); double l = double.Parse(Console.ReadLine()); Console.WriteLine("Please enter rectangle width: "); double w = double.Parse(Console.ReadLine()); Rectangle rectangle = new Rectangle(l, w); Console.WriteLine("Please select output: \n [A]rea \n [P]erimeter \n [B]oth\n"); string a = (Console.ReadLine()); if (a == "a" || a == "A") { Console.WriteLine("Area of rectangle: " + rectangle.Area() + "\n"); } else if (a == "p" || a == "P") { Console.WriteLine(" Perimeter of rectangle: " + rectangle.Perimeter() + "\n"); } else if (a == "b" || a == "B") { Console.WriteLine("Perimeter of rectangle: " + rectangle.Perimeter() + " \n Area of the rectagle: " + rectangle.Area() + "\n"); } } else if (program == "s" || program == "S") { Console.WriteLine("Please enter side of square: "); double side = double.Parse(Console.ReadLine()); Square square = new Square(side); Console.WriteLine("Please select output: \n [A]rea \n [P]erimeter \n [B]oth\n"); string a = (Console.ReadLine()); if (a == "a" || a == "A") { Console.WriteLine("Area of square: " + square.Area() + "\n"); } else if (a == "p") { Console.WriteLine(" Perimeter of square: " + square.Perimeter() + "\n"); } else if (a == "b") { Console.WriteLine("Perimeter of square: " + square.Perimeter() + " \n Area of the square: " + square.Area() + "\n"); } } else if (program == "t" || program == "T") { Console.WriteLine("Please enter triangle side a: "); double aside = double.Parse(Console.ReadLine()); Console.WriteLine("Please enter triangel side b: "); double bside = double.Parse(Console.ReadLine()); Console.WriteLine("Please enter triangel side c: "); double cside = double.Parse(Console.ReadLine()); Triangle triangle = new Triangle(aside, bside, cside); Console.WriteLine("Please select output: \n [A]rea \n [P]erimeter \n [B]oth\n"); string a = (Console.ReadLine()); if (a == "a" || a == "A") { Console.WriteLine("Area of triange: " + triangle.Area() + "\n"); } else if (a == "p" || a == "P") { Console.WriteLine(" Perimeter of triange: " + triangle.Perimeter() + "\n"); } else if (a == "b" || a == "B") { Console.WriteLine("Perimeter of triange: " + triangle.Perimeter() + " \n Area of the triange: " + triangle.Area() + "\n"); } } } }
static void Main(string[] args) { double a, b, c; Console.WriteLine("Введите длину стороны a:"); a = Double.Parse(Console.ReadLine()); Console.WriteLine("Введите длину стороны b:"); b = Double.Parse(Console.ReadLine()); Console.WriteLine("Введите длину стороны c:"); c = Double.Parse(Console.ReadLine()); Triangle triangle = new Triangle(a, b, c); Console.WriteLine($"Периметр треугольника равен {triangle.Perimeter()}, площадь равна {triangle.Area()}."); }