示例#1
0
        private void SetCourcesCount()
        {
            _writer.WriteLine("Enter course count:");
            var input = ReadHelper.GetInputRow(_reader);

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

            _students = new Student[ReadHelper.ParseIntSave(input, "Students Count")];
        }
示例#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());
        }
示例#4
0
        private static OperationType EnterOperation(IReader reader, IWriter writer)
        {
            writer.WriteLine("Enter operation: ");
            var           input = ReadHelper.GetInputRow(reader);
            OperationType operation;

            switch (input)
            {
            case "+":
                operation = OperationType.Add;
                break;

            case "-":
                operation = OperationType.Subtract;
                break;

            case "*":
                operation = OperationType.Multiplay;
                break;

            default:
                throw new ArgumentException();
            }

            return(operation);
        }
示例#5
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")));
        }
示例#6
0
        private Command ReadCommand()
        {
            var input   = ReadHelper.GetInputRow(_reader);
            var command = _commands.FirstOrDefault(c => c.Name.Equals(input, StringComparison.CurrentCultureIgnoreCase));

            if (command == null)
            {
                throw new ArgumentException("Input must be valid command!");
            }

            return(command);
        }
示例#7
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"));
            }
        }
示例#8
0
        private void SetTasksData()
        {
            _writer.WriteLine("Enter tasks data: studentID//courseID//taskName//score");
            while (true)
            {
                var input = ReadHelper.GetInputRow(_reader);

                if (input == _exitCommand)
                {
                    break;
                }

                DoSetTasksData(input);
            }
        }
示例#9
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")
                });
            }
        }