Question: In this assignment, you will be completing the bulletin board you began in PROGRAM 3. We will be adding two major new functionalities: The bulletin

In this assignment, you will be completing the bulletin board you began in PROGRAM 3.

We will be adding two major new functionalities:

  1. The bulletin board will now be able to handle replies to replies, and will display them indented according to their "level" (e.g. Replies are indented 2 spaces; Replies to Replies 4 spaces; Replies to Replies to Replies 6 spaces; etc.) You will use recursive techniques to display this.
  2. The board will now be able to save the entire board (all Message content) to file, and read that file back in; as well as reading in User data from file as you did with the previous bulletin board assignment.

Class Specifications

Click here for specifications of all required classes.

Main function

As before, you should create a very different main function when unit testing your member functions.

User file specifications

Same as for BBoard part 1

Message File Specifications

Click here for the format specifications of the Message file.

Click here for a sample Message file you can use when testing your loadMessages function and overall program.

Output Specifications

Click here for sample output.

Make sure your output matches exactly with the sample runs (given the same inputs) - in particular, note the differences between Topics and Replies.

Step-by-step Approach

Incremental Programming is essential with a project this size.

Copy your work from BBoard (Part 1) assignment.

Message File Read:

  1. Read from a simple file that has only a single Topic, and add the pointer to it to messageList in loadMessages.
  2. Now read from another simple file that has only one Topic and one Reply to that topic, and add it to messageList in loadMessages, and add a pointer to the Reply to the Topic's childList.
  3. Now read in a file with multiple Topics and Replies (you will need a loop, of course!!)

Message File Write:

  1. Build the toFormattedString() function in Reply (Dont forget newline after ). Test it by calling function and outputting the string it returns.
  2. Build the toFormattedString() function in Topic. Test it.
  3. In BBoard::saveMessages() call toFormattedString() on each Message in messageList and print the returning strings to screen/terminal for debugging.
  4. Finally, print the strings to the file instead of the terminal.

Nested Replies and Display:

  1. Modify Message.h, Topic.h and Reply.h files as specified
  2. Modify the print function in Message.cpp to call itself recursively on each of its children after printing the topic itself
  3. In BBoard, modify display and addReply functions as specified.
  4. Have your program run correctly with nested replies

Hints and Tips

Reading from file:

Be very careful assigning "children" (Replies)!!! The children Messages will not be in memory when you are reading the parent, due to their order in the file. One way of doing this would be: For each Message (whether Topic or Reply), maintain a separate string vector that stores the strings following the ":children:" tag (e.g., "5 6 21"). When you finish populating the messageList (or after you close the file), parse the strings (see hint below), construct the Reply objects, and store their POINTERS. e.g.

messageList[i].addChild(messageList[child-1]); 

for each element (child) in the corresponding string. Make sure you add an empty string to any string vector with no :children: tag.

Using stringstream to parse message files:

Review the stringstream sections! (Section 2.6 & 2.7)

void parseForChildren(vector &childList, const string &filename) { ifstream infile(filename); string discard; int childID; string childIdString; // discard  and :children: infile >> discard >> discard; // WARNING: this function is just a HINT - in your actual program you // will need to know when you are dealing with a reply or a topic getline(infile, childIdString); // get string containing all child ids stringstream iss(childIdString); while (iss >> childID) { childList.push_back(childID); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!