Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Shape undefShape = new Shape();

            Console.WriteLine(undefShape.NameOfShape());
            Console.WriteLine(undefShape.AmmountOfSides());
            Console.WriteLine(undefShape.Area());
            Console.WriteLine(undefShape.Circumference());
            Console.WriteLine(undefShape.AStringIwantToKeep());

            Console.WriteLine("----------");

            //undefShape.NumberOfSides = 3;   This shouldn't work. And it doesn't. So it works as expected.
            Line line = new Line();

            Console.WriteLine(line.NameOfShape());
            Console.WriteLine(line.AmmountOfSides());
            Console.WriteLine(line.Area());
            Console.WriteLine(line.Circumference());
            Console.WriteLine(line.AStringIwantToKeep());

            Console.WriteLine("----------");

            Square firstSquare = new Square();

            firstSquare.A = 5;
            firstSquare.B = 10;
            Console.WriteLine(firstSquare.NameOfShape());
            Console.WriteLine(firstSquare.AmmountOfSides());
            Console.WriteLine(firstSquare.Area());
            Console.WriteLine(firstSquare.Circumference());
            Console.WriteLine(firstSquare.AStringIwantToKeep());
            firstSquare.A = 15;
            Console.WriteLine(firstSquare.Area());
            Console.WriteLine(firstSquare.Circumference());

            Console.WriteLine("----------");

            Square secondSquare = new Square(7, 2);

            Console.WriteLine(secondSquare.NameOfShape());
            Console.WriteLine(secondSquare.AmmountOfSides());
            Console.WriteLine(secondSquare.Area());
            Console.WriteLine(secondSquare.Circumference());
            Console.WriteLine(secondSquare.AStringIwantToKeep());
            secondSquare.A = 15;
            Console.WriteLine(secondSquare.Area());
            Console.WriteLine(secondSquare.Circumference());


            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Circle c = new Circle();

            c.r     = 2;
            c.x     = 100;
            c.y     = 100;
            c.color = "red";
            System.Console.WriteLine(c.Area());

            Square s = new Square();

            s.a     = 2;
            c.x     = 100;
            c.y     = 100;
            c.color = "red";
            System.Console.WriteLine(s.Area());

            Rectangle r = new Rectangle();

            r.a     = 2;
            r.b     = 2;
            c.x     = 100;
            c.y     = 100;
            c.color = "red";
            System.Console.WriteLine(r.Area());
        }
Ejemplo n.º 3
0
 public void DefaultSquareContructorCanComputeArea()
 {
     var square = new Square();
     square.Top = 5;
     square.Right = 5;
     square.Bottom = 5;
     square.Left = 5;
     Assert.AreEqual(square.Area(), 25);
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Koło: ");
            var circle = new Circle(5);

            Console.WriteLine(circle.Area());
            Console.WriteLine(circle.Perimeter());

            circle.SetRadious(4.78);
            Console.WriteLine(circle.Area());
            Console.WriteLine(circle.Perimeter());


            Console.WriteLine("Prostokąt: ");
            var rectangle = new Rectangle(3.6, 6);

            Console.WriteLine(rectangle.Area());
            Console.WriteLine(rectangle.Perimeter());

            rectangle.SetSides(3, 5.89);
            Console.WriteLine(rectangle.Area());
            Console.WriteLine(rectangle.Perimeter());


            Console.WriteLine("Kwadrat: ");
            var square = new Square(3);

            Console.WriteLine(square.Area());
            Console.WriteLine(square.Perimeter());

            square.setSide(7.5);
            Console.WriteLine(square.Area());
            Console.WriteLine(square.Perimeter());

            Console.Read();
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            // TODO:
            // Erzeuge Square-Objekt
            Square myFirstSquare = new Square(1, 2, 4);

            // Ausgabe Degrees
            Console.WriteLine("Degrees: " + myFirstSquare.Degrees);
            // Ausgabe Area
            Console.WriteLine("Area: " + myFirstSquare.Area());
            // Ausgabe x1, y1, x2, y2
            Console.WriteLine("X1:" + myFirstSquare.X1 + " Y1:" + myFirstSquare.Y1 + " X2:" + myFirstSquare.X2 + " Y2:" + myFirstSquare.Y2);
            Console.WriteLine("press enter to exit");
            Console.ReadLine();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var square = new Square(5.5);

            Console.WriteLine(square.Area());
            Console.WriteLine(square.CalculatePerimeter());
            Console.WriteLine(square.Draw());

            Console.WriteLine();

            var rectangle = new Rectangle(1.2, 5.5);

            Console.WriteLine(rectangle.Area());
            Console.WriteLine(rectangle.CalculatePerimeter());
            Console.WriteLine(rectangle.Draw());
        }
Ejemplo n.º 7
0
        public void CompareSquare(Square S)
        {
            if (this.Area() == S.Area())
            {
                Console.WriteLine("The area of the rectangles are equal");
            }
            else
            {
                Console.WriteLine("The area of the rectangles are not equal");
            }

            if (this.Perimeter() == S.Perimeter())
            {
                Console.WriteLine("The perimeter of the rectangles are equal");
            }
            else
            {
                Console.WriteLine("The perimeter of the rectangles are not equal");
            }
        }
Ejemplo n.º 8
0
 public void TestMethod1()
 {
     var mySq = new Square(4);
     Assert.AreEqual(16, mySq.Area());
     Assert.AreEqual(16, mySq.Perimeter());
 }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            int input;

            do
            {
                start : Console.WriteLine("Menu");
                Console.WriteLine("1-Create new circle");
                Console.WriteLine("2-Create new Square");
                Console.WriteLine("3-Create new Rectangle");
                Console.WriteLine("4-Out");
                input = Convert.ToInt32(Console.ReadLine());

                switch (input)
                {
                case 1:
                    Console.WriteLine("1-Create new circle 1");
                    var circle = new Circle();
                    Console.Write("Enter radius ");
                    circle.Radius = Convert.ToInt32(Console.ReadLine());

                    Console.WriteLine($"Area of circle :{circle.Area()}");
                    Console.WriteLine($"Perimeter of circle :{circle.Perimeter()}");
                    Console.WriteLine("==========");
                    goto start;

                    break;

                case 2:
                    Console.WriteLine("2-Create new Square");
                    var square = new Square();

                    Console.Write("Enter 1 canh ");
                    square.Side1 = Convert.ToInt32(Console.ReadLine());

                    Console.WriteLine($"Area of square :{square.Area()}");
                    Console.WriteLine($"Perimeter of square :{square.Perimeter()}");
                    Console.WriteLine("==========");
                    goto start;
                    break;

                case 3:
                    Console.WriteLine("3-Create new Rectangle");
                    var rectangle = new Reactangle();

                    Console.Write("Enter width ");
                    rectangle.Slide1 = Convert.ToInt32(Console.ReadLine());
                    Console.Write("Enter Height ");
                    rectangle.Slide2 = Convert.ToInt32(Console.ReadLine());

                    Console.WriteLine($"Area of rectangle :{rectangle.Area()}");
                    Console.WriteLine($"Perimeter of rectangle :{rectangle.Perimeter()}");
                    Console.WriteLine("==========");
                    goto start;
                    break;

                case 4:
                    Console.WriteLine("Out !");
                    break;

                default:
                    Console.WriteLine("Wrong !");
                    goto start;
                    break;
                }
            } while (input > 4);
        }
Ejemplo n.º 11
0
 public void SquareAreaTest()
 {
     Square s = new Square(5);
     Assert.AreEqual(25, s.Area());
 }
Ejemplo n.º 12
0
 public void TestSquareAreaIsZero()
 {
     Square square = new Square();
     square.Area();
 }
Ejemplo n.º 13
0
        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");
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public void SquareContructorCanComputeArea()
 {
     var square = new Square(5);
     Assert.AreEqual(square.Area(), 25);
 }