Exemple #1
0
 private void Add10TestStudents()
 {
     Random random = new Random();
     int addStudents = 10;
     int studentCount = db.Count;
     for (int i = 1; i <= addStudents; i++)
     {
         int studentId = studentCount + i;
         string name = "Student" + studentId.ToString();
         int mark1 = random.Next(56, 78);
         int mark2 = random.Next(79, 86);
         int mark3 = random.Next(90, 100);
         string schoolName = "SchoolName" + random.Next(10).ToString();
         string district = "District" + random.Next(20).ToString();
         Student student = new Student(id: studentId, name: name, mark1: mark1, mark2: mark2, mark3: mark3, schoolName: schoolName, district: district);
         db.AddStudent(student);
     }
 }
Exemple #2
0
 private void AddStudent()
 {
     Console.WriteLine("Enter Id");
     int id;
     string userInput = Console.ReadLine();
     if (!Int32.TryParse(userInput, out id))
     {
         Console.WriteLine("Invalid Id ,Please enter id positive Integer");
         return;
     }
     Console.WriteLine("Enter Name");
     string name = Console.ReadLine();
     Console.WriteLine("Enter Mark1");
     int mark1 = 0;
     userInput = Console.ReadLine();
     if ((!Int32.TryParse(userInput, out id)) || mark1 < 0 || mark1 > 100)
     {
         Console.WriteLine("Invalid Mark1 ,Please enter Mark1 between Mark1>=0 && Mark1<=100");
         return;
     }
     Console.WriteLine("Enter Mark2");
     int mark2 = 0;
     userInput = Console.ReadLine();
     if ((!Int32.TryParse(userInput, out id)) || mark2 < 0 || mark2 > 100)
     {
         Console.WriteLine("Invalid Mark2 ,Please enter Mark2 between Mark2>=0 && Mark2<=100");
         return;
     }
     Console.WriteLine("Enter Mark3");
     int mark3 = 0;
     userInput = Console.ReadLine();
     if ((!Int32.TryParse(userInput, out id)) || mark3 < 0 || mark3 > 100)
     {
         Console.WriteLine("Invalid Mark3 ,Please enter Mark3 between Mark3>=0 && Mark3<=100");
         return;
     }
     Console.WriteLine("Enter SchoolName");
     string schoolName = Console.ReadLine();
     Console.WriteLine("Enter District");
     string district = Console.ReadLine();
     Student student = new Student(id, name, mark1, mark2, mark3, schoolName, district);
     db.AddStudent(student);
 }
Exemple #3
0
 public void AddStudent(Student student)
 {
     students.Add(student);
 }