Ejemplo n.º 1
0
        public int CalculateAgeFromDOB(string input)
        {
            DateTime DOB = new DateTime();

            try
            {
                DOB = Convert.ToDateTime(input);
            }
            catch (FormatException)
            {
                Console.WriteLine("{0} is not a valid date", input);
                ApplicantDetails foo = new ApplicantDetails();
                foo.ItsAllBroken();
            }

            DateTime today = DateTime.Today;

            Age = today.Year - DOB.Year;

            if (DOB > today.AddYears(-Age))
            {
                Age--;
            }

            return(Age);
        }
Ejemplo n.º 2
0
        public Country SelectCountry()
        {
            Console.WriteLine("Please select your contry of residence from the list below");
            Console.WriteLine("1. England");
            Console.WriteLine("2. Wales");
            Console.WriteLine("3. Scotland");
            Console.WriteLine("4. Ireland");
            Console.WriteLine("5. Northern Ireland");
            Console.WriteLine("6. Any Other Country");

            int selected = Convert.ToInt32(Console.ReadLine());

            if (selected == 1)
            {
                return(Country.England);
            }
            else if (selected == 2)
            {
                return(Country.Wales);
            }
            else if (selected == 3)
            {
                return(Country.Scotland);
            }
            else if (selected == 4)
            {
                return(Country.Ireland);
            }
            else if (selected == 5)
            {
                return(Country.NorthernIreland);
            }
            else if (selected == 6)
            {
                return(Country.Other);
            }
            else
            {
                ApplicantDetails foo = new ApplicantDetails();
                foo.ItsAllBroken();
                return(Country.Other);
            }
        }