Пример #1
0
        public static void Main()
        {
            Console.WriteLine("Triangle area : {0}", CalculateTriangleArea(3, 4, 5));

            Console.WriteLine("Digit to english name : {0}", DigitToEnglishName(5));

            Console.Write("Find biggest element (5, -1, 3, 2, 14, 2, 3) : ");
            Console.WriteLine(FindBiggestElement(5, -1, 3, 2, 14, 2, 3));

            Console.WriteLine();
            Console.WriteLine("Print number in format:");
            PrintNumberInFormat(1.3, "f");
            PrintNumberInFormat(0.75, "%");
            PrintNumberInFormat(2.30, "r");

            Console.WriteLine();
            double distance = CalculateDistance(3, -1, 3, 2.5);
            Console.WriteLine("Distance = {0}", distance);

            bool horizontal = IsHorizontal(-1, 2.5);
            bool vertical = IsVertical(3, 3);
            Console.WriteLine("Horizontal ? -> " + horizontal);
            Console.WriteLine("Vertical ? -> " + vertical);

            Student peter = new Student("Peter", "Ivanov");
            peter.Location = "Sofia";
            peter.DateOfBirth = "17.03.1992";
            //peter.OtherInfo = "From Sofia, born at 17.03.1992";

            Student stella = new Student("Stella", "Markova");
            stella.Location = "Vidin";
            stella.DateOfBirth = "03.11.1993";
            stella.Profession = "gamer";
            stella.OtherInfo = "high results";
            //stella.OtherInfo = "From Vidin, gamer, high results, born at 03.11.1993";

            Console.WriteLine();
            Console.WriteLine("Peter date of birth: {0}", peter.DateOfBirth);
            Console.WriteLine("Stella date of birth: {0}", stella.DateOfBirth);
            Console.WriteLine("{0} is older than {1} -> {2}",
                peter.FirstName, stella.FirstName, peter.IsOlderThan(stella));
        }
Пример #2
0
        public bool IsOlderThan(Student secondStudent)
        {
            //DateTime firstDate =
            //    DateTime.Parse(this.OtherInfo.Substring(this.OtherInfo.Length - 10));
            //DateTime secondDate =
            //    DateTime.Parse(other.OtherInfo.Substring(other.OtherInfo.Length - 10));
            //return firstDate > secondDate;

            bool isOlder = false;

            isOlder = (Convert.ToDateTime(this.DateOfBirth) < Convert.ToDateTime(secondStudent.DateOfBirth));

            return isOlder;
        }