Extracting data from a file

Hi, I am doing a project for school and I am stuck at coming up with a function definition for the program. Here is the decleration of the function that have been given:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Extracts data from a file for a collection of courses.
 * Courses contain a title, crn, days, time and instructor
 * @param aInputFile the stream to retrieve data for courses
 * @param aCourses the collection of courses
 * @pre the stream must be opened and ready to read data from.
 *				the collection of courses must be large enough
 *				to hold all courses within an input file, i.e.,
 *				the collection can't be size 1 if there are 100
 *				courses in the input file.
 * @post the stream has extracted all the data for courses and stopped
 *				at an eof. The collection of courses contains all the
 *				course data from the stream.
 * @return the number of courses constructed as a result of the extraction
 * @see Courses.h
 */
int putDataInCourses(/* fill in param list */);


Assuming I already have the file open succesfully and inside this file this is what it contain:

courseOneTitle,courseOneCRN,courseOneDays,courseOneTime,courseOneInstructor\n
courseTwoTitle,courseTwoCRN,courseTwoDays,courseTwoTime,courseTwoInstructor\n

We also have a teacher custom library call "Course.h" and we suppose to use the member function from there.
Course ()
string getTitle () const
void setTitle (const string &aTitle)
int getCRN () const
void setCRN (int aCRN)
string getDays () const
void setDays (const string &aDays)
string getTime () const
void setTime (const string &aTime)
string getInstructor () const
void setInstructor (const string &aInstructor)

Hopefuly someone can help me because I have been stuck on this function for over 2 days now and it is in the middle of the project so I cannot move on until I can come up with the function.

Thanks
1
2
3
4
int /*should be a member of the class*/putDataInCourses(/* the variables to be put inside the object */)
{
   //call class setters
}


...or something similar :?
Last edited on
Topic archived. No new replies allowed.