Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ mini02_social_media project. You are not allowed to make any change class Account { private: string username_; string password_; string following_[20]; unsigned nFollowing_; public: //constructors

image text in transcribed

image text in transcribed

image text in transcribed

C++

"mini02_social_media" project. You are not allowed to make any change class Account \{ private: string username_; string password_; string following_[20]; unsigned nFollowing_; public: //constructors Account(const string\& username); //Accessors string get_following(const string\& key = "") const; string to_string() const; //mutator bool follow(const string\& username); bool unfollow(const string\& username); \}; "mini02_social_media" project. You are not allowed to make any change to the class definition. Here are more details about the private data members: - The username_data member is to store the username for an account. - The password_data member is to store a secured password for the account. - The following_data member is to store the usernames of all the accounts followed by the current account owner. - The nFollowing_data member is to store the number of accounts followed by the current account owner. Your task is to implement the member functions of the Account class in the "Account.cpp". The "main.cpp" file is to include code that supports the thorough testing of these member functions. You are welcome but not required to create additional functions to support your testing. Make a copy of the Mini 02 Sample Run Document and, as you make progress in testing the functions, capture related screenshots that demonstrate proper testing of related functions into the document. At the end, save the document in PDF and upload it to Canvas. Here are more details for the public member functions you need to implement and test: Account: : Account (const string \& username); This function is to create an Account object using the username provided as the value for the username_member of the new object. Any new account just constructed should not have followed anyone. In addition, the constructor shall randomly create a secured password that satisfies the following criteria: - It shall be between 10 and 15 characters. - It shall contain at least one uppercase letter, at least one lowercase letter, at least one digit. - It shall not contain any character that is not a letter or a digit. - It shall not follow any pattern that would be easy to recognize when someone sees a few passwords generated by your program. For example, avoid always having a letter for the first character or always having two digits in a row or always using the same letter(s)/digits and just changing the order. Be creative in your randomness. Do not copy others' algorithms. string Account: :to_string () const; This function is to return a string object that contains details of the invoking Account object. It shall be called from the main function to help you demonstrate the other member functions properly update related data members of an Account object. For example, given the following statements in the main function: Account a( "demo"); cout a.to_string () end l The following output would be generated: The user demo has 30YD2an53dhC as their password and is following 0 account(s). And here is a sample output of cout a.to_string () endl; after it follows a few people: The user demo has 30YD2an53dhC as their password and is following 10 account(s). bool Account::follow (const string\& username); This function is to return false if the invoking account is already following the username provided or the array is already at its capacity. No change shall then be made to any data member of the invoking account. Otherwise, it adds the username to the following_array data member, updates the nFollowing_ data member, and returns true. bool Account: : unfollow (const strings username); This function is to return false if the invoking account is not currently following the username provided. No change shall then be made to any data member of the invoking account. Otherwise, it removes the username from the following__ array data member by shifting the related elements forward, updates the nFollowing_data member, and returns true. string Account: : get_following (const string\& key = "") const; This function is to perform a keyword search through the following_array and return a string of all matching usernames, formatted in a nice tabular format. You are required to use a stringstream object along with parametric manipulator to help you organize the format of the string to be returned. It shall not change any of the data members of the object. If no match is found, the function shall return an empty string. By def ault, the value for key is an empty string, indicating the returned string of the function shall include all usernames in the following_array, from the oldest to the newest. On the other hand, if a non-empty string is presented for the key parameter, the returned string shall include only usernames that contain the key as its substring. For example, here is a sample output of cout a.get_following () endl; showing all 10 amazing early female computer scientists being followed: And here is a sample output of cout a.get_following ("et") endl; showing only those with the string "et" as part of their names

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions