Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement CourseRecordIO. readCourse() To finish the CourseRecordIo class and pass all of the CourseRecordIOTest s, you need to implement CourseRecordIo. readCourse(). The method receives a

image text in transcribedimage text in transcribedimage text in transcribed

Implement CourseRecordIO. readCourse() To finish the CourseRecordIo class and pass all of the CourseRecordIOTest s, you need to implement CourseRecordIo. readCourse(). The method receives a String which is a line from the input file. An example line might be: CSC 116, Intro to Programming - Java, 001, 3, jdyoung2, MW, 0910, 1100 or CSC 216, Software Development Fundamentals, 601, 3, jctetter, A You can use a Scanner to process the String parameter. You must break the line up into tokens by using the comma character (e.g., ' ' ' as a delimiter. A delimiter is a string that is used to separate or break apart a larger string. The default delimiter for scanner is white space. You can change the delimiter using the Scanner.useDelimiter() method. After updating the delimiter, any call to Scanner.next() will return the token before the next delimiter. So for our example, CSC 216, Software Development Fundamentals, 601, 3, jctetter, A the first call to Scanner. next() would return a string "CSC 216", the second call to Scanner.next() would return a string "Software Development Fundamentals", etc. When reading the values for credits, startTime, or endTime, you can use Scanner. nextInt (). Once you break the line into tokens, you can construct a Course object and return it from the method. There are two places where code that you work with may lead to an exception for invalid values in the input string: > NoSuchElementException or InputMismatchException: if you receive these when processing the input, catch them and throw an IllegalArgumentException to the caller (which in this case is CourseRecordIO. readCourseRecords ()). > IllegalArgumentException: when constructing a Course with invalid values, the Course class will throw an IllegalArgumentException. In this case DO NOT catch the exception! Instead, let the exception propagate to the caller (which in this case is CourseRecordIo.readCourseRecords()) Use the fields and constructors of the cour ce class to help vou determine what type each token should be. The tokens will always be in the order of: If the meeting days string is NOT "A", then you'll need to read in the last two tokens. If there are any additional tokens after the expected last one, an IllegalArgumentException should be thrown. The high level structure of the method is provided in the pseudocode, below. You do not have to implement the method this way, but it will be useful for getting started. JAVA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions