private static Student[] GetRandomStudents(int n) { Student[] students = new Student[n]; for (int i = 0; i < n; i++) { students[i] = RandomStudent(); } return students; }
//this method will generate list of count number students with random names and grades public static List<Student> CreateList(int count) { List<Student> studentsArray = new List<Student>(); //two predifined arrats with first and last names from which the random generator will pick values string[] firstNames = new string[] { "Ivan", "Georgi", "Stoyan", "Pavel", "Asen", "Nikolai", "Lyubomir", "Atanas", "Petar", "Martin", "Vasil" }; string[] lastNames = new string[] { "Ivanov", "Georgiev", "Stoyanov", "Pavlov", "Asenov", "Nikolaev", "Lyubomirov", "Atanasov", "Petrov", "Martinov", "Vasilev" }; Random generator = new Random(); for (int i = 0; i < count; i++) { string nameFirst = firstNames[generator.Next(0, firstNames.Length)]; string nameLast = lastNames[generator.Next(0, lastNames.Length)]; //a formula I found on the interent for returning double numbers within certain range //in our case between 2 and 6 double grade = Math.Round((generator.NextDouble() * 4 + 2), 2); Student temp = new Student(nameFirst, nameLast, grade); studentsArray.Add(temp); } return studentsArray; }
public static void Main() { Human.Worker hugo = new Human.Worker(); Human.Student paul = new Human.Student(); }