Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                AgeException ae = new AgeException();

                Console.WriteLine($"Enter your age : ");
                int age = Convert.ToInt32(Console.ReadLine());
                ae.validateAge(age);
                Console.WriteLine($"Age is {age}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                NameException ne = new NameException();
                Console.WriteLine($"Enter your name : ");
                string name = Console.ReadLine();
                ne.validateName(name);
                Console.WriteLine($"Name is {name}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                DateException de = new DateException();
                Console.WriteLine($"Enter a date");
                DateTime date = Convert.ToDateTime(Console.ReadLine());

                de.validateDate(date);
                Console.WriteLine($"Date is {date}");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }