Esempio n. 1
0
 public static void DisplayInfo(Student student)
 {
     Console.WriteLine(student.ToString());
 }
Esempio n. 2
0
        public static void AddStudent()
        {
            Console.Clear();
            // Get student name
            string name = GetUserInput("Please enter student's name");

            while (name == string.Empty)
            {
                Console.WriteLine("Please enter a valid name");
                name = Console.ReadLine();
            }

            // address
            string address = GetUserInput("Please enter student's address");

            while (address == string.Empty)
            {
                Console.WriteLine("Please enter a valid address");
                address = Console.ReadLine();
            }

            // program
            string program = GetUserInput("Please enter student's program");

            while (program == string.Empty)
            {
                Console.WriteLine("Please enter a valid program");
                program = Console.ReadLine();
            }

            // year
            string year = GetUserInput("Please enter student's year");
            int    nYear;

            while (!int.TryParse(year, out nYear))
            {
                Console.WriteLine("Please enter a valid year");
                year = Console.ReadLine();
            }

            // fee
            string fee = GetUserInput("Please enter student's fee");
            double dFee;

            while (!double.TryParse(fee, out dFee))
            {
                Console.WriteLine("Please enter a valid fee");
                fee = Console.ReadLine();
            }

            Student newStudent = new Student(name, address, program, nYear, dFee);

            try
            {
                listOfPersons.Add(newStudent);
                Console.WriteLine("Added Student\n");
            }
            catch
            {
                Console.WriteLine("Error while adding student\n");
            }
        }