Пример #1
0
        private static DistanceWithType CalcDistance(double x1, double y1, double x2, double y2)
        {
            bool isHorizontal = (y1 == y2);
            bool isVertical   = (x1 == x2);

            double distance = Math.Sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));

            DistanceWithType distanceWithType = new DistanceWithType(distance, isHorizontal, isVertical);

            return(distanceWithType);
        }
Пример #2
0
        private static void Main()
        {
            double triangleArea = CalcTriangleArea(3, 4, 5);

            Console.WriteLine("The triangle area is: {0}", triangleArea);

            int    number = 5;
            string digit  = ConvertNumberToDigit(number);

            Console.WriteLine("The number {0} is -> {1}", number, digit);

            int[] arrayOfNumbers = new int[] { 5, -1, 3, 2, 14, 2, 3 };
            int   maxNumber      = FindMax(arrayOfNumbers);

            Console.WriteLine("The max element in [{0}] is: {1}", string.Join(", ", arrayOfNumbers), maxNumber);

            Console.WriteLine("\n----- Formatted numbers -----");
            PrintAsNumber(1.3, NumberFormats.FixedPoint);
            PrintAsNumber(0.75, NumberFormats.Percent);
            PrintAsNumber(2.30, NumberFormats.RoundTrip);
            Console.WriteLine("-----------------------------\n");

            DistanceWithType distanceWithType = CalcDistance(3, -1, 3, 2.5);
            bool             isHorizontal     = distanceWithType.IsHorizontal;
            bool             isVertical       = distanceWithType.IsVertical;
            double           distance         = distanceWithType.Distance;

            Console.WriteLine("The distance is: {0}", distance);
            Console.WriteLine("Horizontal? " + isHorizontal);
            Console.WriteLine("Vertical? " + isVertical);

            Student peter = new Student("Peter", "Ivanov", "From Sofia, born at 17.03.1992");

            Student stella = new Student("Stella", "Markova", "From Vidin, gamer, high results, born at 03.11.1993");

            bool peterIsOlderThanStella = peter.IsOlderThan(stella);

            Console.WriteLine("{0} older than {1} -> {2}", peter.FirstName, stella.FirstName, peterIsOlderThanStella);
        }