Пример #1
0
        private void AddStudent()
        {
            StudentNameToAdd.Trim();

            if (StudentNameToAdd == "")
            {
                throw new ArgumentException("Please type in a name for the student.");
            }

            if (StudentNameToAdd.Length < 10)
            {
                throw new ArgumentException("We only take students whose name is longer than 10 characters.");
            }
            if ((StudentScoreToAdd < 60) || (StudentScoreToAdd > 100))
            {
                throw new ArgumentException("We only take students whose score is between 60 and 100. please give a valid score");
            }

            DateTime      Now = DateTime.Now;
            StringBuilder SB  = new StringBuilder();

            SB.Append("Student ");
            SB.Append(StudentNameToAdd);
            SB.Append(" is added @ ");
            SB.Append(Now.ToString());

            Students.AddAStudent(StudentNameToAdd, StudentScoreToAdd, Now, SB.ToString());
        }