Assignment Task: This assignment comprises a single exercise. The files for use in this assignment are available in Moodle as a zip file.
Submission of this assignment will be via FASER.
Introduction:
In this assignment, you will develop a basic social media content management platform (e.g. think of it as X (twitter) or Reddit). The platform simulates a discussion of people and their posts with two types of distinct users:
1. Users: Individuals who read and write posts.
2. Managers: Individuals responsible for moderating the platform by setting and updating the content restrictions (i.e., blocked words or phrases). They also moderate who can become a manager.
Your program will needs to display statistics about users reputation and help identify the top 10 most problematic users based on their reputation scores.
Key Objectives
1. Provide a system where Users can read and write posts.
2. Provide a system where Managers can set and manage blocked content.
3. Display the top 10 most problematic users who have accumulated the lowest reputation scores (or are tied at zero and have multiple moderated posts).
4. Allow Users to view their statistics (accumulated or average scores).
5. Implement a moderation engine that censors blocked content within posts.
User and Manager Options:
User Options
1. Read/Write Post:
- Read a post: Randomly select a post from the platform's database and present it to the user. After reading, the user can choose to read another post, report the post (which lowers the post's author's reputation), or exit.
- Write a post: Prompt the user to write a post (up to 140 characters) and append it to the platform's post file. Need Assignment Help?
2. View Your Statistics: Show the user's accumulated reputation score and average reputation per post. These scores should be updated frequently and should use STL algorithms (of your choice).
3. Display Top 10 Most Problematic Users: Sort the users by their reputation score (lowest first using a class operator overload). If there's a tie at zero, break it by the number of moderated posts they have triggered. Display the bottom 10. Use STL sorting and iterators.
4. Exit the Program
Manager Options
1. Reset Moderation Content: Clear all previously added banned words or phrases.
2. Add Blocked Content: Add new words or phrases that should be censored.
3. Add Another Manager: Only an existing manager can add a new manager by specifying their name and registration number.
4. Set the Sample File: Set or change the name of the text file that contains the platform posts.
5. Exit the Program
Content Moderation Engine
The engine must censor posts that contain blocked words or phrases. Every censored word or phrase should be replaced by a series of 'X's of the same length, and every post that has been censored should include the #moderated post tag at the end.
- Consider a "word" as a sequence of non-whitespace characters containing more than one letter.
- Remove punctuation at the start or end of words, but leave punctuation and digits that appear in the middle of words.
- Convert all input to lowercase before checking for blocked content.
Examples:
- If "hate" is blocked: Original: "They truly hate her ideas." Moderated: "They truly XXXX her ideas. #moderatedpost"
- If "cried all night" is blocked (a phrase): Original: "He cried all night after the announcement." Moderated: "He XXXXX XXX XXXXX after the announcement. #moderatedpost"
Classes and Files
You will be provided with files in the Assignment2files folder, including:
- Person.h and Person.cpp: A complete Person class (you may add extra members but do not alter existing ones except where noted).
- User.h and Manager.h: Declarations for derived classes of Person. You must implement these in User.cpp and Manager.cpp, respectively, following the specifications in the comments.
You may add extra member functions to these classes, but only define them in the .cpp files.
Additional Class: ReadPosts
You will have a ReadPosts class that:
- Reads a large text file of platform posts.
- Each record in the file may look like: userID postID post content date/time
- You will be given a partial implementation and a header file. Use these as provided.
- Implement a findPost function to select a random post from a multimap or similar container.
- If any file cannot be opened, terminate gracefully with an error message.
Main Program Requirements
1. Prompt for a username (or manager name) and determine their role.
2. If a User does not exist yet, create a new one and inform them using a try-catch statement.
3. If a Manager line is found, load their details. Only an existing Manager can add another.
4. Use a template function login to read from a user/manager file. For Users: Read registration, name, and scores, and create User objects. For Managers: Read registration number and name, then create a Manager object.
5. After login, provide the respective menu options as described earlier.
6. You MUST use STL algorithms (for each, sort, etc.) and iterators, where pointed, but do not stop there.
7. Handle file I/O errors gracefully.
Challenge
Make the ReadPosts class behave like a custom iterable container (similar to a linked list). Use this custom iterator in the top 10 calculation and in displaying the top 10 most problematic users.