Course CSV to Courses
Up until now we've used public constructors to create instances of our classes.
But there are other patterns for enabling class creation, and this problem explores one.
Specifically, we're going to show how to deserialize a CSV
String into instances of a custom class.
Create a class named
Course should not provide a public constructor, although you will probably want to create a
Course should provide method named
fromCSV on a companion object
which takes a single
String argument and returns an array of
Course maintains a
department and a
Here's how they are loaded from a CSV
Given the following CSV contents:
CS, 125 IE, 333 MUS, 230
You should return an array containing three
Course instances: the first with
number="125", the second with
Your array should contain the courses in the same order in which they appear in the CSV
require that the passed
String is not empty.
To complete this problem you'll want to review our previous work with CSV
Strings, apply what you know about
companion objects, and determine how to create a private constructor. Have fun!