Beispiel #1
0
    static void Main()
    {
        Console.Write("Enter the year of your birth: ");
        int iYear = Int32.Parse(Console.ReadLine());

        Console.Write("And the month: ");
        int iMonth = Int32.Parse(Console.ReadLine());

        Console.Write("And the day: ");
        int iDay = Int32.Parse(Console.ReadLine());

        SuperDate sdBirthday = new SuperDate(iYear, iMonth, iDay);
        SuperDate sdMoonWalk = new SuperDate(1969, 7, 20);

        if (sdBirthday > sdMoonWalk)
        {
            Console.WriteLine("You were born {0} days after the moon walk.",
                              sdBirthday - sdMoonWalk);
        }

        else if (sdBirthday == sdMoonWalk)
        {
            Console.WriteLine("You were born on the day of the moon walk.");
        }

        else
        {
            Console.WriteLine("You were born {0} days before the moon walk.",
                              sdMoonWalk - sdBirthday);
        }
    }
    static void Main()
    {
        Console.Write("Enter the year of your birth: ");
        int iYear = Int32.Parse(Console.ReadLine());

        Console.Write("And the month: ");
        int iMonth = Int32.Parse(Console.ReadLine());

        Console.Write("And the day: ");
        int iDay = Int32.Parse(Console.ReadLine());

        SuperDate sdBirthday = new SuperDate(iYear, iMonth, iDay);
        SuperDate sdMoonWalk = new SuperDate(1969, 7, 20);

        if (sdBirthday > sdMoonWalk)
            Console.WriteLine(
                "You were born {0:N0} days after the moon walk.",
                sdBirthday - sdMoonWalk);

        else if (sdBirthday == sdMoonWalk)
            Console.WriteLine(
                "You were born on the day of the moon walk.");

        else
            Console.WriteLine(
                "You were born {0:N0} days before the moon walk.",
                sdMoonWalk - sdBirthday);
    }
 public static SuperDate Subtract(SuperDate sdLeft, int daysRight)
 {
     return new SuperDate(sdLeft.CommonEraDay - daysRight);
 }
 public static int Subtract(SuperDate sdLeft, SuperDate sdRight)
 {
     return sdLeft.CommonEraDay - sdRight.CommonEraDay;
 }
 public static SuperDate Add(int daysLeft, SuperDate sdRight)
 {
     return sdRight + daysLeft;
 }
 // Arithmetic operators
 public static SuperDate Add(SuperDate sdLeft, int daysRight)
 {
     return new SuperDate(sdLeft.CommonEraDay + daysRight);
 }