Beispiel #1
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")));
        }
Beispiel #2
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")
                });
            }
        }