COMP 142: Project 6 --- Hogwarts Facebook

Update, 4/25

I have added a walkthrough for getting started with the project. See the walkthrough here and the diagram here.

Overview

Though electronic devices don't work at Hogwarts School of Witchcraft and Wizardry (because magic), recently as part of the Muggle Studies curriculum, the professors have bewitched some computers to run inside the Hogwarts castle, and of course the students discovered social media. The professors have blocked access to Facebook however, so you need to create a simplified version of the social media platform for them to access.

You will create a program that runs a simplified version of Facebook, specifically designed for Hogwarts. The program will read in a text file giving a list of students, which Hogwarts houses they are in, and who is friends with whom. Then your program will allow the user to browse Facebook through a menu.

Getting started

Make a new CLion project and create a new C++ class called facebook. See the project 4 webpages if you forget how to do this. You should now have three files, called main.cpp, facebook.h, and facebook.cpp.

Place the following code in each files: main.cpp facebook.h facebook.cpp

Program details

You should use a struct in your program to hold each Facebook user. The declaration of the struct should be the following (note this is already defined in facebook.h for you):
struct person
{
  string name;
  string house;
  vector<person*> friends;
};
The struct contains the following information about a person on Facebook: You will notice that the facebook class is mostly empty --- you should add appropriate fields (variables) and methods (functions) as you see fit. The only thing you should not change is the all_people field --- this variable stores a vector of pointers to people: one person for everyone on Facebook.

The entire friendship network is maintained through this vector of people. All of the individual people in the network should be allocated on the heap (using new), and then you will add pointers to those people to the all_people vector.

You should make sure to add a destructor to the facebook class so that the memory used to store all the people will be deallocated at the end of the program; this will be done by using delete. Note that you will need a loop to do this, since you will have to delete each individual person one at a time.

Operations your program must support

How the program should work

The text file

This file is a very simple encoding of all the people and friendships that the Hogwarts version of Facebook should be loaded with at the beginning (other people or friendships might be added later by the user as the program runs). Reading and processing this file should be straightforward. It will be even easier if you make functions for adding a new person and adding a new friendship, because you can just call these functions while processing the file, and also use the same functions later when the user needs those options.

Here is a sample file.

Coding style

Sample input and output

Sample input/output that uses the text file from earlier.

Your program's output should match mine.

Your program should never crash, and you should print error messages if the user selects an option that requires a name but the name given does not correspond to someone on Facebook. For instance, if someone chooses to print all the friends of a certain person, and they mistype the person's name, you can just print an error message and return to the menu; you do not have to re-prompt for their name.

How to submit

Upload your code to Moodle. Please upload all three files (main.cpp, facebook.h, and facebook.cpp) and no others.

Challenge problem

Add in the ability for people to make (text-only) posts to Facebook. Posts should consist of a string with some text, with an optional list of Facebook users that are tagged in the post. For instance, Harry might post "Totally retrieved the Sorcerer's stone earlier tonight --- thanks for the help @Ron and @Hermione! Quirrell always weirded me out lol." Add a menu option to let a user make post and tag people in it. Then add a menu option to display all posts where a certain person is tagged.