コード例 #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);
        }
    }
コード例 #2
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: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);
    }
コード例 #3
0
 public static SuperDate Subtract(SuperDate sdLeft, int daysRight)
 {
     return new SuperDate(sdLeft.CommonEraDay - daysRight);
 }
コード例 #4
0
 public static int Subtract(SuperDate sdLeft, SuperDate sdRight)
 {
     return sdLeft.CommonEraDay - sdRight.CommonEraDay;
 }
コード例 #5
0
 public static SuperDate Add(int daysLeft, SuperDate sdRight)
 {
     return sdRight + daysLeft;
 }
コード例 #6
0
 // Arithmetic operators
 public static SuperDate Add(SuperDate sdLeft, int daysRight)
 {
     return new SuperDate(sdLeft.CommonEraDay + daysRight);
 }