예제 #1
0
        public void EditByIndex(int index)
        {
            int day;
            int month;
            int year;

            char choice = 'a';

            Io.PrintPropertyList();
            choice = Io.InputChar();

            switch (choice)
            {
            case '1':
                Console.Write("Last name: ");
                Students[index].LastName = Io.InputName();
                break;

            case '2':
                Console.Write("First name: ");
                Students[index].FirstName = Io.InputName();
                break;

            case '3':
                Console.Write("Patronymic: ");
                Students[index].Patronymic = Io.InputName();
                break;

            case '4':
                Console.Write("BirthDay: ");
                day = Io.InputInt();
                Console.Write("BirthMonth: ");
                month = Io.InputInt();
                Console.Write("BirthYear: ");
                year = Io.InputInt();
                Students[index].BirthDate = new DateTime(year, month, day);
                break;

            case '5':
                Console.Write("EnterDay: ");
                day = Io.InputInt();
                Console.Write("EnterMonth: ");
                month = Io.InputInt();
                Console.Write("EnterYear: ");
                year = Io.InputInt();
                Students[index].EnterDate = new DateTime(year, month, day);
                break;

            case '6':
                Console.Write("Group index: ");
                Students[index].GroupIndex = Io.InputChar();
                break;

            case '7':
                Console.Write("Faculty: ");
                Students[index].Faculty = Io.InputName();
                break;

            case '8':
                Console.Write("Specialization: ");
                Students[index].Specialization = Io.InputName();
                break;

            case '9':
                Console.Write("Performance: ");
                Students[index].Performance = Io.InputDouble();
                break;
            }
        }
예제 #2
0
        public static void Start()
        {
            const string path    = @"C:\Users\Дмитрий Соколенко\source\repos\DotNet\sokolenko05DN\file.txt";
            const string xmlPath = @"C:\Users\Дмитрий Соколенко\source\repos\DotNet\sokolenko05DN\file.xml";
            var          pigsty  = new StudentContainer();
            char         choice  = 'a';
            int          intChoice;
            string       strChoice = "";


            Console.WriteLine("Hello World! Our copany introduces the next level of data base - AllBase");
            Console.WriteLine("The array of Student object is created, my lord.");

            Io.ReadStContainerFromFile(path, pigsty);


            while (choice != '0')
            {
                PrintMenu();
                Console.Write("Make a choice: ");
                choice = Io.InputChar();

                switch (choice)
                {
                case '1':
                    PrintOptions();
                    Console.WriteLine("3 - All students");
                    Console.Write("Make a choice: ");
                    intChoice = Io.InputInt();

                    if (intChoice != 3)
                    {
                        Console.WriteLine("Enter criteria: ");
                        strChoice = Console.ReadLine();

                        Io.ShowContainer(StudentContainer.Search(strChoice, pigsty, intChoice));
                    }
                    else
                    {
                        Io.ShowContainer(pigsty);
                    }


                    break;

                case '2':
                    pigsty.AddStudent(Io.InputStudent());
                    break;

                case '3':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.DeleteStudent(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;

                case '4':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.ShowByIndex(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;

                case '5':
                    if (pigsty.Size() > 0)
                    {
                        Console.Write("Input the index: ");
                        pigsty.EditByIndex(Io.InputInt());
                    }
                    else
                    {
                        Console.Write("Container is empty");
                    }
                    break;

                case '6':
                    PrintOptions();
                    Console.Write("Make a choice: ");
                    intChoice = Io.InputInt();

                    Console.WriteLine("Enter criteria: ");
                    strChoice = Console.ReadLine();
                    pigsty.DeleteStudents(StudentContainer.Search(strChoice, pigsty, intChoice));
                    break;

                case '7':
                    PrintMathematicOptions();
                    Console.Write("Make a choice: ");
                    intChoice = Io.InputInt();

                    StudentContainerProcessing.Del del = null;
                    switch (intChoice)
                    {
                    case 0:
                    {
                        del = StudentContainerProcessing.CalculateAverageAge;
                        break;
                    }

                    case 1:
                    {
                        del = StudentContainerProcessing.CalculateAverageAcademicPerformance;
                        break;
                    }
                    }

                    PrintOptions();

                    Console.Write("Make a choice: ");
                    intChoice = Io.InputInt();

                    Console.WriteLine("Enter criteria: ");
                    strChoice = Console.ReadLine();

                    Console.WriteLine(del?.Invoke(StudentContainer.Search(strChoice, pigsty, intChoice)));
                    break;

                case '8':
                    Serialization.SaveCollectionInXML(pigsty, xmlPath);
                    break;

                case '9':
                    pigsty = Serialization.LoadCollectionFromXML(xmlPath);
                    break;
                }
            }

            Io.WriteStContainerToFile(path, pigsty);
        }