Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication32
- {
- public class Program
- {
- static void Main(string[] args)
- {
- Journal journal = CreateJournal();
- Console.WriteLine("кого искать?");
- Student result = journal.Search(Console.ReadLine());
- if (result != null)
- Console.WriteLine("{0} {1} {2}", result.Firstname, result.Lastname, result.Rating);
- else
- Console.WriteLine("Поиск не дал результата");
- }
- private static Journal CreateJournal()
- {
- Journal journal = new Journal();
- journal.Addstudent("John", "Smith", new int[] {5,4,4,5,3});
- journal.Addstudent("Han", "Solo", new int[] {5,5,5,4,5});
- journal.Addstudent("Johny", "Cash", new int[] {3,3,5,3,4});
- journal.Addstudent("Axel", "Foley", new int[] {4,5,4,5,5});
- return journal;
- }
- }
- class Journal
- {
- private List<Student> students = new List<Student>();
- public void Addstudent(string studentFname, string studentLname, int[] rate)
- {
- Student student = new Student();
- student.Firstname = studentFname;
- student.Lastname = studentLname;
- student.Rating = rate;
- students.Add(student);
- }
- public Student Search(string searchfirstname)
- {
- foreach (Student i in students)
- if (i.Firstname == searchfirstname)
- return i;
- return null;
- }
- public List <Student> Searchstudents(string searchfirstname)
- {
- List<Student> Searchresult = new List<Student>();
- foreach (Student i in students)
- {
- if (i.Firstname == searchfirstname)
- Searchresult.Add(i);
- }
- return Searchresult;
- }
- }
- public class Student
- {
- public string Firstname;
- public string Lastname;
- public int[] Rating = new int[5];
- public static double Calc(int[] calcRate)
- {
- int sum = 0;
- for (int i = 0; i < calcRate.Length; i++)
- sum += calcRate[i];
- return sum / calcRate.Length;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement