Order Now  +1 678 648 4277 

Social Media Assignment Solution with C++

Social Networking Site Problem 


A social networking site is an online platform that people use to build social networks or social relationships with other people who share similar personal or career content, interests, activities, backgrounds, or real-life connections.

For this project, we are going to create a simple social networking application for an organization with up to 100 people. Each person can then become friends with those people in the organization.

Person Data (provided in proj2_data.txt):

Emi, Carson, 23, 8370814

  • First name (string)
  • Last name (string)
  • Age (int)
  • ID (int)

Assignment Description

Initially, you should work to write the functions in the Person class. A Person is made up of the data listed above and an array of Friends. Every Person is limited to the maximum number of friends defined by the constant MAX_FRIENDS. The Person class will be used repeatedly when the roster is loaded into the Organization. An Organization is made up of a roster that is limited to the constant MAX_PEOPLE. The FriendFinder class manages the Organization and provides the menu interface for the application.

Project 2 Data











































#include < iostream> #include < string> #include "Organization.h" //Must be implemented before FriendFinder #include "Person.h" //Must be implemented before FriendFinder using namespace std; class FriendFinder { public: // Name: FriendFinder // Desc - Default constructor for application for finding friends // Preconditions - Creates a Person and an organization // Postconditions - Welcomes user and calls Start() FriendFinder(); // Name: GetDetails // Desc - Asks user for their first name, last name, age, and ID to populate m_me // Preconditions - None // Postconditions - Populates information related to m_me void GetDetails(); // Name: DisplayMenu // Desc - Displays main menu for application // Preconditions - None // Postconditions - Called from Start updates integer passed void DisplayMenu(int &choice); // Name: Start // Desc - Main function running FriendFinder // Calls GetDetails // Populates data for organization // Continually calls DisplayMenu until someone enters 4 (exit) // Preconditions - m_me and m_organization are created but not populated // Postconditions - Runs until user enters 4. Thanks user for usage. Ends application void Start(); private: Person m_me; //Information about me Organization m_organization; //Information about my organization }; #endif


#include < iostream> #include < string> #include < fstream> #include "Person.h" //Must be implemented before Organization using namespace std; //Constants const int MAX_PEOPLE = 40; //Maximum number of people in organization const string FILE_NAME = "proj2_data.txt"; class Organization { public: // Name: Organization // Desc - Default constructor for Organization // Preconditions - None // Postconditions - Organization is created (empty) with 0 people in the roster Organization(); // Name: SetName // Desc - Sets m_name by asking user for name // Preconditions - m_name exists // Postconditions - Asks user for the organization name and populates m_name void SetName(); // Name: LoadRoster // Desc - Sets m_fileName by asking user. Then populates all of the people loaded from file // Preconditions - m_fileName exists. m_roster empty // Postconditions - Asks user for m_fileName. Loads data from file and populates m_roster void LoadRoster(); // Name: DisplayRoster // Desc - Displays a numbered list of everyone in the roster (starts at 1) // Preconditions - m_roster is populated // Postconditions - Displays a numbered list of people void DisplayRoster(); // Name: GetPerson // Desc - Displays a list of people in m_roster and user enters number of desired person. // Returns pointer of that person in m_roster // Preconditions - m_roster is populated // Postconditions - Returns pointer for the person chosen from list Person* GetPerson(); // Getters string GetName() { return m_name; } private: string m_name; //Name of the organization string m_fileName; //Name of the input file int m_numRoster; //Number of people in roster Person m_roster[MAX_PEOPLE]; //Roster of people in the organization }; #endif


#include < iostream> #include < string> using namespace std; //constants const int MAX_FRIENDS = 10; //Maximum number of friends a person can have class Person { public: // Name: Person // Desc - Default Constructor for a Person // Preconditions - Creates a Person with no data associated with it // Postconditions - a Person is created Person(); // Name: Person // Desc - Overloaded Constructor for a Person // Preconditions - Creates a Person with passed data // Postconditions - a Person is created Person(string, string, int, int); // Name: AddFriend // Desc - A person pointer is stored from the roster of people in an organization // Preconditions - A person pointer is passed // Postconditions - A person pointer is added to this person's m_friend's array // if not at maximum and not already in the array void AddFriend(Person*); // Name: RemoveFriend // Desc - Removes a person pointer from this person's m_friend array // Preconditions - Person pointer exists in m_friend // Postconditions - Person is removed from m_friend and all pointers are moved towards front void RemoveFriend(Person*); // Name: CheckID // Desc - Checks to see if a specific person ID exists in m_friends - Note: IDs will always be unique in proj2 // Preconditions - m_friends is populated // Postconditions - Returns true if id exists in m_friends else false bool CheckID(int); // Name: DisplayFriends // Desc - Displays information about each friend in the m_friend array // Preconditions - People are in the m_friend array // Postconditions - Displays information about person object in array void DisplayFriends(); // Name: DisplayDetails // Desc - Displays information about this person // Preconditions - Person data is populated // Postconditions - Displays information about person object void DisplayDetails(); // Name: SetDetails // Desc - Used as a setter for first name, last name, age, and id // Preconditions - Person already created // Postconditions - Member variables populated void SetDetails(string, string, int, int); // add a friend operator so it is easier to print a person friend ostream& operator<<(ostream& os, Person const& p) { return os << p.m_fName << " " << p.m_lName << " (" << p.m_age << " yrs) " << p.m_ID; } // getter for array of friends. Required for option when user wants to remove a Friend Person** GetFriends() { return m_friends; } int GetFriendsCount() { return m_friendCount; } private: string m_fName; //Person's first name string m_lName; //Person's last name int m_age; //Person's age int m_ID; //Person's ID Person* m_friends[MAX_FRIENDS]; //Person's array of friends int m_friendCount; //Person's count of friends }; #endif //Protects against multiple inclusion