コード例 #1
0
        /// <summary>
        /// adds a tester and confime that it can be added
        /// </summary>
        /// <param name="t">tester to add</param>
        /// <param name="TesterAge">how old he is in years</param>
        /// <param name="TesterMonth">how old he is in months</param>
        /// <param name="TesterDay">how old he is in days</param>
        /// /// <param name="Age">how old he is</param>
        public void AddTester(Tester t)
        {
            TimeSpan Age = DateTime.Now - t.testerBirthDate;

            if (t.testerId.Length != 9)
            {
                throw new Exception("ID must have 9 digits");
            }
            if (t.testerName == "")
            {
                throw new Exception("You must enter a tester's first name");
            }
            if (t.testerLast == "")
            {
                throw new Exception("You must enter a tester's last name");
            }
            if (t.testerBirthDate == null)
            {
                throw new Exception("You must enter the birth date of the tester");
            }
            if (t.testerBirthDate > DateTime.Now)
            {
                throw new Exception("Birth date cannot be in the furture");
            }
            if ((Age.TotalDays / 365) >= Configuration.MinAgeOfTester)
            {//the age in days,we devided it in 365 (days of each year so it will be in years
                try { dal.AddTester(t); }
                catch (Exception e)
                { throw e; }
            }


            else
            {
                throw new Exception("You are too young to be a Tester");
            }
        }