Exemplo n.º 1
0
        private void SetCourcesCount()
        {
            _writer.WriteLine("Enter course count:");
            var input = ReadHelper.GetInputRow(_reader);

            _cources = new Course[ReadHelper.ParseIntSave(input, "Course count")];
        }
Exemplo n.º 2
0
        private void SetStudentsCount()
        {
            _writer.WriteLine("Enter students count: ");
            var input = ReadHelper.GetInputRow(_reader);

            _students = new Student[ReadHelper.ParseIntSave(input, "Students Count")];
        }
Exemplo n.º 3
0
        static int[] EnterNumbers(IReader reader, IWriter writer)
        {
            writer.WriteLine("Enter 2 numbers: ");
            var input = ReadHelper.GetInputRow(reader);

            return(ReadHelper.SplitInput(input, 2, " ").Select(e => ReadHelper.ParseIntSave(e, "Number")).ToArray());
        }
Exemplo n.º 4
0
        private Complex ReadComplexNumber()
        {
            var input = ReadHelper.GetInputRow(_reader);
            var parts = ReadHelper.SplitInput(input, 2, _inputDelimiter);

            return(new Complex(ReadHelper.ParseIntSave(parts[0], "Complex number real part"),
                               ReadHelper.ParseIntSave(parts[1], "Complex number imaginary part")));
        }
Exemplo n.º 5
0
        private void SetStudentsData()
        {
            _writer.WriteLine("Enter students data formated name//courseId");
            for (var i = 0; i < _students.Length; i++)
            {
                var input = ReadHelper.GetInputRow(_reader);
                var parts = ReadHelper.SplitInput(input, 2, _inputDelimiter);

                var student = new Student(parts[0]);
                _students[i] = student;
                SignStudentToCourse(student, ReadHelper.ParseIntSave(parts[1], "CourseId"));
            }
        }
Exemplo n.º 6
0
        private void DoSetTasksData(string input)
        {
            //studentId courseId taskName//score
            var parts     = ReadHelper.SplitInput(input, 4, _inputDelimiter);
            var studentId = ReadHelper.ParseIntSave(parts[0], "StudentId");
            var student   = GetStudentById(studentId);
            var courseId  = ReadHelper.ParseIntSave(parts[1], "CourseId");

            if (student.CourseId != courseId)
            {
                // TODO custom exception
                throw new InvalidOperationException($"Student with id: {studentId} is not sign to course with id: {courseId}");
            }

            student.AddTask(new Task(parts[2], ReadHelper.ParseFloatSave(parts[3], "Task Id")));
        }
Exemplo n.º 7
0
        private void SetCoursesData()
        {
            _writer.WriteLine("Enter course data formated courseName//duration//capacity");

            for (var i = 0; i < _cources.Length; i++)
            {
                var input = ReadHelper.GetInputRow(_reader);
                var parts = ReadHelper.SplitInput(input, 3, _inputDelimiter);

                _cources[i] = new Course(new CourseArgs()
                {
                    Name       = parts[0],
                    Duration   = ReadHelper.ParseIntSave(parts[1], "Duration"),
                    Capability = ReadHelper.ParseIntSave(parts[2], "Capability")
                });
            }
        }