Guest User

Untitled

a guest
Sep 27th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. using namespace std;
  5.  
  6.  
  7. int main(int argc, char **argv) {
  8. if (argc > 1) {
  9. istringstream buf(argv[1]);
  10. int max_voters;
  11. buf >> max_voters;
  12. }
  13. if(argc > 2)
  14. string filename = argv[2];
  15.  
  16. VoterDatabase vd = new VoterDatabase(max_voters);
  17. string option = "";
  18. while(option != "Quit") {
  19. cout << "Pick an option [Login,New,Save,Load,Report,Quit]: ";
  20. cin >> option;
  21. if(option == "Login") {
  22. string attempt;
  23. cout << "Enter user id: ";
  24. cin >> attempt;
  25.  
  26. int j = vd.check_userid(attempt);
  27. if(j != -1) {
  28. Voter v = vd.get_voter(j);
  29. string real_pass = v.get_passwd();
  30.  
  31. cout << "Enter password for this user: ";
  32. cin >> attempt;
  33. if(attempt == real_pass) {
  34. cout << "Logged in." << endl;
  35. while(option2 != "Logout") {
  36. cout << "Pick an option [Update,Passwd,View,Donate,Report,Logout]: ";
  37. cin >> option;
  38.  
  39. if(option == "Update") {
  40. v.update();
  41. }
  42. else if(option == "Passwd") {
  43. v.set_passwd();
  44. }
  45. else if(option == "View") {
  46. v.view();
  47. }
  48. else if(option == "Donate") {
  49. v.donate();
  50. }
  51. else if(option == "Report") {
  52. c.report();
  53. }
  54. else
  55. cout << "Incorrect option. Try again." << endl;
  56. }
  57. cout << "Logged out." << endl;
  58. }
  59. else
  60. cout << "Incorrect password. Logging out." << endl;
  61. }
  62. else
  63. cout << "No such user id found." << endl;
  64. }
  65. else if(option == "New") {
  66. vd.new_voter();
  67. }
  68. else if(option == "Save") {
  69.  
  70. }
  71. else if(option == "Load") {
  72.  
  73. }
  74. else if(option == "Report") {
  75. vd.report();
  76. }
  77. else if(option == "Quit"){
  78. char c;
  79. do {
  80. cout << "Would you like to save Y or N: ";
  81. cin >> c;
  82. if(!(c == 'Y' || c == 'N'))
  83. cout << "Please enter a valid option" << endl;
  84. else if(c == 'Y'){
  85. vd.save();
  86. cout << "File Saved, goodbye!" << endl;
  87. }
  88. else{
  89. cout << "Goodbye!" << endl;
  90. }
  91. } while(!(c == 'Y' || c == 'N'));
  92. }
  93. else
  94. cout << "Incorrect option. Try again." << endl;
  95. }
  96. cout << "Program quit successfully." << endl;
  97.  
  98. return 0;
  99. }
Add Comment
Please, Sign In to add comment