Beispiel #1
0
        public void TestDateUtilities()
        {
            Console.WriteLine("Testing Date Utilities\nDate Formats\n");
            // tests different forms of date inputs and makes sure they all convert to standard format "dd/mm/yyyy"
            String[] testQuery = { "12-08-2003",
                                   "12th August 2003",
                                   "2003-8-12",
                                   "August 12 2003",
                                   "2003/08/12",
                                   "12/8/2003",
                                   "August 12th 2003",
                                   "12th, August, 2003",
                                   "12-Aug-2003",
                                   "12-Aug-03",
                                   "Aug-12-03",
                                   "12-8-03",
                                   "12/08/03" };
            for (int i = 0; i < testQuery.Length; i++)
            {
                Console.Write(testQuery[i] + " >> " + DateUtilities.DateFormat(testQuery[i]));
                if (DateUtilities.DateFormat(testQuery[i]).Equals("12/08/2003"))
                {
                    Console.Write(" >> OK\n");
                }
                else
                {
                    Console.Write(" >> ERROR\n");
                }
            }
            Console.WriteLine("\nLeap Years\n");
            // Test different date formats and different years for leap years
            String[] leapQuery = { "12-08-2000", "1900/08/12", "12-Aug-04", "12-08-1975" };
            for (int i = 0; i < leapQuery.Length; i++)
            {
                Console.WriteLine(leapQuery [i] + " >> " + DateUtilities.IsLeapYear(leapQuery[i]));
            }
            Console.WriteLine("\nBirthdays\n");
            // Test the birthday utility isBirthday
            DateTime today = DateTime.Now;

            String[] birthdayQuery = { today.Day + "/" + today.Month + "/" + today.Year,
                                       today.Day + "/" + today.Month + "/2008",
                                       today.Day + "/01/" + today.Year,
                                       "1/" + today.Month + "/09" };
            for (int i = 0; i < birthdayQuery.Length; i++)
            {
                Console.WriteLine(birthdayQuery [i] + " >> " + DateUtilities.IsBirthday(birthdayQuery [i]));
            }
            Console.WriteLine("\nZodiac Signs\n");
            // Tests different date formats and the getZodiac method
            String[] zodiacQuery = { "01/01/2000", "01-02-1967", "23rd March 1952", "12-Sep-07" };
            for (int i = 0; i < zodiacQuery.Length; i++)
            {
                Console.WriteLine(zodiacQuery [i] + " >> " + DateUtilities.GetZodiac(zodiacQuery [i]));
            }
        }
Beispiel #2
0
        public virtual void DisplayInfo()
        {
            String format = "{0,-15} {1}";             // used to set the layout of the display

            Console.WriteLine(String.Format(format, "ID:", accountID));
            Console.WriteLine(String.Format(format, "Name:", firstName + " " + lastName));
            // Format date of birth .. using the DateUtilities Class methods
            Console.WriteLine(String.Format(format, "Birth Date:", DateUtilities.DateFormat(dob)));
            // Format money using "{0:C}" which formats a number into currency ( e.g $1.00 )
            Console.WriteLine(String.Format(format, "Balance:", String.Format("{0:C}", balance)));
        }
Beispiel #3
0
 // Method to display all customers born in a leap year and their zodiac signs
 internal static void GetLeapYearCustomers(Customer[] array)
 {
     DisplayTitle("Leap Years and Zodiac Signs");
     foreach (Customer customer in array)
     {
         if (DateUtilities.IsLeapYear(customer.AccessDob))
         {
             customer.DisplayInfo();
             Console.WriteLine(String.Format("{0,-15} {1}", "Zodiac:", DateUtilities.GetZodiac(customer.AccessDob)) + "\n");
         }
     }
     waitForKey();
 }
Beispiel #4
0
        // Method to display the Customer with largest balance and display
        internal static void GetMaximumBalance(Customer[] array)
        {
            DisplayTitle("Max Balance Customer");
            // set initial customer position
            int pos = 0;

            for (int i = 1; i < array.Length; i++)
            {
                if (array[i].AccessBalance > array[pos].AccessBalance)
                {
                    pos = i;
                }
            }
            // display the customer with max balance
            array[pos].DisplayInfo();
            // is it their birthday?
            if (DateUtilities.IsBirthday(array[pos].AccessDob))
            {
                Console.WriteLine("\nHappy Birthday!");
            }
            waitForKey();
        }
Beispiel #5
0
 // Method to display the Youngest customer
 internal static void GetYoungest(Customer[] array)
 {
     DisplayTitle("Youngest Customer");
     array[DateUtilities.GetYoungest(array)].DisplayInfo();
     waitForKey();
 }