Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- int main(int argc, char **argv) {
- if (argc > 1) {
- istringstream buf(argv[1]);
- int max_voters;
- buf >> max_voters;
- }
- if(argc > 2)
- string filename = argv[2];
- VoterDatabase vd = new VoterDatabase(max_voters);
- string option = "";
- while(option != "Quit") {
- cout << "Pick an option [Login,New,Save,Load,Report,Quit]: ";
- cin >> option;
- if(option == "Login") {
- string attempt;
- cout << "Enter user id: ";
- cin >> attempt;
- int j = vd.check_userid(attempt);
- if(j != -1) {
- Voter v = vd.get_voter(j);
- string real_pass = v.get_passwd();
- cout << "Enter password for this user: ";
- cin >> attempt;
- if(attempt == real_pass) {
- cout << "Logged in." << endl;
- while(option2 != "Logout") {
- cout << "Pick an option [Update,Passwd,View,Donate,Report,Logout]: ";
- cin >> option;
- if(option == "Update") {
- v.update();
- }
- else if(option == "Passwd") {
- v.set_passwd();
- }
- else if(option == "View") {
- v.view();
- }
- else if(option == "Donate") {
- v.donate();
- }
- else if(option == "Report") {
- c.report();
- }
- else
- cout << "Incorrect option. Try again." << endl;
- }
- cout << "Logged out." << endl;
- }
- else
- cout << "Incorrect password. Logging out." << endl;
- }
- else
- cout << "No such user id found." << endl;
- }
- else if(option == "New") {
- vd.new_voter();
- }
- else if(option == "Save") {
- }
- else if(option == "Load") {
- }
- else if(option == "Report") {
- vd.report();
- }
- else if(option == "Quit"){
- char c;
- do {
- cout << "Would you like to save Y or N: ";
- cin >> c;
- if(!(c == 'Y' || c == 'N'))
- cout << "Please enter a valid option" << endl;
- else if(c == 'Y'){
- vd.save();
- cout << "File Saved, goodbye!" << endl;
- }
- else{
- cout << "Goodbye!" << endl;
- }
- } while(!(c == 'Y' || c == 'N'));
- }
- else
- cout << "Incorrect option. Try again." << endl;
- }
- cout << "Program quit successfully." << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment