internal static void Main() { Console.WriteLine(CalculateTriangleArea(3, 4, 5)); Console.WriteLine(NumberToDigit(5)); Console.WriteLine(FindMaxNumber(5, -1, 3, 2, 14, 2, 3)); PrintAsNumber(1.3, "float"); PrintAsNumber(0.75, "percent"); PrintAsNumber(2.30, "padLeft"); Console.WriteLine(CalculateDistanceBetweenTwoPoints(3, -1, 3, 2.5)); Console.WriteLine("Horizontal? " + CheckIfLinePositionIsHorizontal(3, -1, 3, 2.5)); Console.WriteLine("Vertical? " + CheckIfLinePositionIsVertical(3, -1, 3, 2.5)); 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"); Console.WriteLine(peter.OtherInfo.Length - 10); Console.WriteLine(peter.GetBirthdayFromOtherInfo(peter)); Console.WriteLine(stella.GetBirthdayFromOtherInfo(stella)); Console.WriteLine("{0} older than {1} -> {2}", peter.FirstName, stella.FirstName, peter.IsOlderThan(stella)); }
public bool IsOlderThan(Student other) { if (!(other is Student)) { throw new ArgumentException("Argumet is not an instnce of Student"); } if (string.IsNullOrEmpty(other.OtherInfo)) { throw new ArgumentNullException("Other student otherInfo is null or empty"); } DateTime firstStudentBirthday = this.GetBirthdayFromOtherInfo(this); DateTime secondStudentBirthday = other.GetBirthdayFromOtherInfo(other); return(firstStudentBirthday < secondStudentBirthday); }
public bool IsOlderThan(Student other) { if (!(other is Student)) { throw new ArgumentException("Argumet is not an instnce of Student"); } if (string.IsNullOrEmpty(other.OtherInfo)) { throw new ArgumentNullException("Other student otherInfo is null or empty"); } DateTime firstStudentBirthday = this.GetBirthdayFromOtherInfo(this); DateTime secondStudentBirthday = other.GetBirthdayFromOtherInfo(other); return firstStudentBirthday < secondStudentBirthday; }