Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤷🤷🤷 #30

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add 'delete question' to menu
MiKoronjoo committed Dec 1, 2018
commit c018d355a774fd487fd3aedda1601a7a432c264c
7 changes: 7 additions & 0 deletions User.cpp
Original file line number Diff line number Diff line change
@@ -139,3 +139,10 @@ void User::edit_content(int num, string &body) {
num %= contents.size();
contents[num].body = body;
}

void User::delete_content(int num) {
num %= contents.size();
auto it = contents.begin();
it += num;
contents.erase(it);
}
1 change: 1 addition & 0 deletions User.h
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ class User : public AbstractUser {
static void print_questions();
void print_content(int num);
void edit_content(int num, string& body);
void delete_content(int num);

private:
static string salt;
6 changes: 5 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ int main() {
}
case MenuState::QUESTIONS: {
loggedInUser->print_content(content_num);
cout << "p. previous question\nn. next question\ne. edit question\nb. back to main menu\n";
cout << "p. previous question\nn. next question\ne. edit question\nd. delete question\nb. back to main menu\n";
cin >> choice;
switch (choice) {
case 'p': { // previous question
@@ -167,6 +167,10 @@ int main() {
loggedInUser->edit_content(content_num, question);
break;
}
case 'd': { // delete question
loggedInUser->delete_content(content_num);
break;
}
case 'b': { // back to main menu
menuState = MenuState::LOGGED_IN;
break;