Advertisement
Guest User

People List

a guest
Nov 22nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. // BMV.cpp : Defines the entry point for the console application.
  2. // Used on VS 2017
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <vector>
  7. #include <fstream>
  8. #include <string>
  9. using namespace std;
  10. //TO_DO: Need to make an if for start a new list (basically delete everything in the old list)
  11.  
  12. int main()
  13. {
  14. ofstream fout; //of and if stream function thingies
  15. ifstream fin;
  16. cout << "Welcome to Matthew's Barmitzvah list. Would you like to edit? (y/n)" << endl; // First Entry point. Basic Opening. Make a view list option available
  17. string start;
  18. cin >> start;
  19. string answer;
  20. while (start == "y") { //while loop for first entry point
  21. cout << "To add a new person, type(add), to delete a person, type(delete), and to view the list, type(view)" << endl; //Second Entry point. Asks what they want to do
  22. cin >> answer;
  23. vector<string> people(1);
  24. if (answer == "add") { //the add a person(s) option
  25. cout << "Keep typing in people, type (done) when finished" << endl << endl;
  26. string newPerson;
  27. cin >> newPerson;
  28. fout.open("People.txt", ios_base::app);
  29. while (newPerson != "done") {
  30. fout << newPerson << endl;
  31. cin >> newPerson;
  32. }
  33. fout.close();
  34. }
  35. if (answer == "delete") { // the delete a person(s) option. Have it so it views list before they put it an input of person(s) to delete. Also have option for deleting of whole list. Or possibly even say like people 1-5 (<-- example)
  36.  
  37. }
  38. if (answer == "view") { // the view list option. To view the list
  39. fin.open("People.txt");
  40. string person;
  41. while (!fin.eof()) {
  42. fin >> person;
  43. if (fin.good()) {
  44. cout << person << endl;
  45. }
  46. }
  47. fin.close();
  48. }
  49. cout << endl << "What would you like to do next? (add, delete, view) If nothing, type (exit) to exit." << endl; // Third Entry Point. Repetitive. Last entry point allowing for repeated options
  50. cin >> answer;
  51. cout << endl;
  52. }
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement