Esempio n. 1
0
        //=====================================================method to add student==================================================
        public static void AddStudent()
        {
            //variables for inputting students' info
            string name;
            //phone is a string because int wasn't big enough to hold high area code numbers
            string phone;
            string email;
            //check variable used to make sure numbers are entered for a phone number.  Ints ran into upper range problems with area codes that were too high so I used longs.
            long check;
            Console.Write("Enter Name\n");
            name = Console.ReadLine().Trim();
            Console.Write("Enter 10 digit Phone number\n");
            //store input data
            string input = Console.ReadLine();
            //checking for valid phone number length and type
            try
            {
                check = Convert.ToInt64(input);
            }
            catch
            {
                Console.WriteLine("Phone number must be 10 numerical digits");
                return;
            }
            if (input.ToString().Length != 10)
            {
                Console.WriteLine("Phone number entered is not 10 digits, please try again");
                return;
            }
            else
            {
                phone = input;
            }
            Console.Write("Enter Email address\n");
            email = Console.ReadLine().Trim();

            if (name != "" && email != "")
            {
                //create an empty classItem list to pass to constructor to be used when scheduling classes
                List<classItem> classesWith = new List<classItem>();
                //set bool value to false on all students
                bool isTeacher = false;
                Student s = new Student(name, phone, email, isTeacher, classesWith);
                if (people.Contains(s))
                {
                    Console.WriteLine("The name, phone number, or email entered is already taken, please enter a new one");
                }
                else
                {
                    people.Add(s);
                    //bool used in scheduling a class for error checking
                    hasStudent = true;
                    Console.WriteLine("{0} added successfully!", s.Name);
                }
            }
            else
            {
                Console.WriteLine("One or more fields left empty, please try again");
            }
        }
Esempio n. 2
0
 //displays student-specific information
 public static void displayStudentInfo(Student s)
 {
     if (s.CoursesWith.Count == 0)
     { Console.WriteLine("Student is not enrolled in any classes"); }
     else
     {
         Console.WriteLine("Information regarding courses this student is taking:");
         foreach (classItem ci in s.CoursesWith)
         {
             Console.WriteLine("\tCourse name: {0}\n\tTeacher name: {1}\n\tClassroom number: {2}\n\tCourse time: {3}", ci.Course.CourseName, ci.Teacher.Name, ci.Room.RoomNumber, ci.CourseTimes.TimeFrame);
         }
     }
 }