Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static List<Student> _students = new List<Student>();
- static public void AddStudent()
- {
- bool again = true;
- try
- {
- Console.Clear();
- Console.WriteLine("UIS - ADDING A NEW STUDENT");
- Console.WriteLine("---------------------------");
- Console.Write("Enter student name: ");
- string name = Console.ReadLine();
- Console.Write("Enter student's last name: ");
- string surname = Console.ReadLine();
- Console.Write("Enter the specialty of the student: ");
- string specialty = Console.ReadLine();
- Console.Write("Enter the year of birth of the student: ");
- while (again)
- {
- string input = Console.ReadLine();
- if (Int32.TryParse(input, out int year))
- {
- Student newStundent = new Student(name, surname, specialty, year);
- _students.Add(newStundent);
- Console.WriteLine("\nCreated " + newStundent);
- again = false;
- }
- else
- {
- Console.WriteLine("Please enter the number!");
- Console.ReadKey();
- Console.Clear();
- Console.WriteLine("UIS - ADDING A NEW STUDENT");
- Console.WriteLine("---------------------------");
- Console.WriteLine("Enter student name: " + name);
- Console.WriteLine("Enter student's last name: " + surname);
- Console.WriteLine("Enter the specialty of the student: " + specialty);
- Console.Write("Enter the year of birth of the student: ");
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement