Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.27 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "windows.h"
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <cstdlib>
  7. using namespace::std;
  8.  
  9. int cls() {
  10.     system("cls");
  11.     return 0;
  12. }
  13.  
  14. int addrecord() {
  15.     string fname,lname,dob,inv,yn,mem,age;
  16.     ofstream writerec,listrec;
  17.     cls();
  18.     cout << "::Add Record::\nEnter the scout's information.\nFirst Name: ";
  19.     cin >> fname;
  20.     if (fname=="q") goto end;
  21.     cout << "Last Name: ";
  22.     cin >> lname;
  23.     if (lname=="q") goto end;
  24.     cout << "Age: ";
  25.     cin >> age;
  26.     if (age=="q") goto end;
  27.     cout << "Date of Birth: ";
  28.     cin >> dob;
  29.     if (dob=="q") goto end;
  30.     cout << "Investiture Date: ";
  31.     cin >> inv;
  32.     if (inv=="q") goto end;
  33.     cout << "Membership Number: ";
  34.     cin >> mem;
  35.     if (mem=="q") goto end;
  36. loop:
  37.     cout << "\nCreate record? [y/n]\nResponse: ";
  38.     cin >> yn;
  39.     if (yn=="n") goto end;
  40.     if (yn=="y") goto create;
  41.     if (yn=="q") goto end;
  42.     cls();
  43.     cout << "ERROR: " << yn << " is not a recognised parameter.";
  44.     Sleep(2000);
  45.     goto loop;
  46.  
  47. create:
  48.     cls();
  49.     cout << "Creating record...";
  50.     writerec.open("data/" + fname + lname + ".record");
  51.     if (writerec.is_open()) {
  52.         writerec << "Scout: ";
  53.         writerec << fname;
  54.         writerec << " ";
  55.         writerec << lname;
  56.         writerec << " - Membership #";
  57.         writerec << mem;
  58.         writerec << " - Invested: ";
  59.         writerec << inv;
  60.         writerec << "\nDOB: ";
  61.         writerec << dob;
  62.         writerec << " - Age: ";
  63.         writerec << age;
  64.         writerec << "\n--------------------------------------------------------------------\n";
  65.         writerec.close();
  66.         listrec.open("data/recordlist/" + fname + lname);
  67.         if (listrec.is_open()) {
  68.         listrec << " ";
  69.         listrec.close();
  70.         goto finish;
  71.         }
  72.         cls();
  73.         cout << "ERROR: Could not write to list file. Record could not be created. Please Seek help with this error.";
  74.         goto end;
  75. finish:
  76.         Sleep(500);
  77.         cls();
  78.         cout << "Record Successfully Created!";
  79.         goto end;
  80.     }
  81.     cls();
  82.     cout << "ERROR: Could not write to file";
  83.     Sleep(2000);
  84. end:
  85.     return 0;
  86. }
  87.  
  88. int editrecord() {
  89.     string edit;
  90.     cout << "::Edit Record::\nPlease select a record to edit from the list below";
  91.     system("dir/b data\recordlist");
  92.     cout << "\nTo view a record, type it's name.\nResponse: ";
  93.     cin >> edit;
  94.     ifstream filecheck;
  95.     filecheck.open("data/recordlist/" + edit);
  96.  
  97.  
  98.  
  99.  
  100.     cout << "::Edit Record::\n1. Add Achievement\n2. Add Comment\n3. Manually Edit Record (not reccommended!)\n4. Return to Main Menu";
  101.     return 0;
  102. }
  103.  
  104. int viewrecord() {
  105.     string view,line,path;
  106.     int lines(0);
  107. view:
  108.     cls();
  109.     cout << "::View Record::\n";
  110.     cout << "A list of all records in the system is below\n\n";
  111.     system("dir/b data\\recordlist");
  112.     cout << "\nTo view a record, type it's name.\nResponse: ";
  113.     cin >> view;
  114.     ifstream record;
  115.     if (view=="q") goto end;
  116.      record.open ("data/" + view + ".record");
  117.     if (record.is_open()) {
  118.         cls();
  119.         cout << "Viewing Record: " << view << "\n\n";
  120.         while (! record.eof())
  121.         {
  122.             getline (record,line);
  123.             cout << line << endl;
  124.             ++lines;
  125.         }
  126.         cout << "\n--End of Record--\n\nTotal Lines: " << lines << "\n\n";
  127.         system("pause");
  128.         record.close();
  129.     } else {
  130.         cls();
  131.         system("color 47");
  132.         cout << "ERROR: Record not found or cannot be opened.";
  133.         Sleep(3000);
  134.         system("color 17");
  135.     }
  136.     cls();
  137. end:
  138.     return 0;
  139. }
  140.  
  141. int main() {
  142.     system("color 17");
  143.     int menu;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement