Question: C++ help needed [FACEBOOK 2010] My part is to code update and remove section. I know you can't code fully with this info only. So...
C++ help needed
[FACEBOOK 2010]
My part is to code update and remove section. I know you can't code fully with this info only. So... Please provide code "examples" for my part only (end of the page).
functions receive as parameter.
#include using namespace std;
const int MSGSIZE = 50; // Maximum size for a posting message const int CAPACITY = 5; // Maximum number of posts
struct Facebook { int id; char msg[MSGSIZE]; int likes; };
void displayTimeline(const Facebook timeline[], int usedSize, int selected); void doLikePost(Facebook timeline[], int usedSize, int selected); int doAddPost(Facebook timeline[], int& usedSize); int addPost(Facebook timeline[], int& usedSize, const char message[]); int getNextId(Facebooktimeline[], int& usedSize); int selectPost(const Facebook timeline[], int usedSize);
/* * timeline = timeline in which the post is to be updated * usedSize = number of posts in the timeline * selected = position number of currently selected post * If 'selected' represents a valid array position, the * selected posts will be updated. * If 'selected' is not valid a 'no post is selected message' will be * displayed and no changes will be made. */ void doUpdatePost(Facebook timeline[], int usedSize, int selected);
/* * Remove currently selected post. * timeline = timeline in from which the entry is to be removed * usedSize = number of posts in the timeline * If 'selected' represents a valid array position: * the selected post will be removed * usedSize will be updated to reflect the updated number of posts in the timeline * selected will be updated to -1 * If 'selected' is not valid a 'no post is selected message' will be * displayed and no changes will be made. */ void doRemovePost(Facebook timeline[], int& usedSize, int& selected);
int main() { Facebook timeline[CAPACITY]; // timeline int choice; // User's menu choice int usedSize = 0; // Num of posts in the timeline int selected = -1; // Currently selected post int tmp; // Temporary variable
do { cout << "1. Show Timeline"; cout << "2. Select post"; cout << "3. Add post"; cout << "4. Update Selected post"; cout << "5. Like Selected post"; cout << "6. Remove Selected post"; cout << "7. Exit"; cout << endl; cout << "Select: ";
cin >> choice;
cin.ignore();
switch (choice) { case 1: displayTimeline(timeline, usedSize, selected); break; case 2: tmp = selectPost(timeline, usedSize); if (tmp > -1) selected = tmp; break; case 3: tmp = doAddPost(timeline, usedSize); if (tmp > -1) selected = tmp; break; case 4: doUpdatePost(timeline, usedSize, selected); break; case 5: doLikePost(timeline, usedSize, selected); break; case 6: doRemovePost(timeline, usedSize, selected); break; }
} while (choice != 7);
return 0; }
My part
void doUpdatePost(Facebook timeline[], int usedSize, int selected) {
//your code here. the function should first verify that the selected parameter is actually a valid position within the used portion of the array. Use cin.getline to retrieve the line of input from the user.//
}
void doRemovePost(Facebook timeline[], int& usedSize, int& selected) {
// your code here. the function should first verify that the selected parameter is actually a valid position within the used portion of the array. //
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
