Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <Windows.h>
  4. #include <fstream>
  5.  
  6. #include "MenuFunctions.h"
  7.  
  8. using namespace std;
  9.  
  10.  
  11. void MenFunctions::Add() {
  12. system("cls");
  13. cout << "Write your name and surname: ";
  14. cin >> name >> surname;
  15. cout << "Now we will generate a PIN that you will use to login to our system. \n";
  16. cout << "You can change it whenever you want! \n";
  17. //Generate();
  18. cout << "OK, here is your PIN: " << PIN << ". Remember it! That let you login to our system! \n";
  19. cout << "Now log in to our system. \n";
  20. system("pause");
  21. system("cls");
  22. return Menu();
  23. }
  24.  
  25. void Menu() {
  26. cout << "------GUBE BANK------ \n\n";
  27. cout << "---------------------\n";
  28. cout << "1. Log in\n";
  29. cout << "2. Create an account\n";
  30. cout << "3. Exit\n";
  31. cout << "---------------------\n\n";
  32. cout << "Choose an option <1-3>: ";
  33. int choose;
  34. cin >> choose;
  35.  
  36. switch (choose) {
  37. case 1: {
  38. //login();
  39. }
  40. break;
  41. case 2: {
  42. //Add();
  43. }
  44. break;
  45. }
  46. }
  47. void MenFunctions::Generate() {
  48. srand(time(NULL));
  49.  
  50. for (int i = 1; i <= 6; i++)
  51. {
  52. PIN = rand() % 49 + 1;
  53. Sleep(1000);
  54. }
  55. }
  56.  
  57. void MenFunctions::SaveContent() {
  58. fstream plik;
  59. plik.open("DANE.bnk", ios::out | ios::app);
  60.  
  61. plik << name << endl;
  62. plik << surname << endl;
  63. plik << PIN << endl;
  64.  
  65. plik.close();
  66. }
  67.  
  68. void MenFunctions::ReadContent() {
  69.  
  70. string linia;
  71. int nr_linii = 1;
  72.  
  73. fstream plik;
  74. plik.open("DANE.bnk", ios::in);
  75.  
  76. if (plik.good() == false) cout << "Nie mozna otworzyc pliku!";
  77.  
  78. while (!plik.eof())
  79. {
  80. switch (nr_linii)
  81. {
  82. case 1: name = linia; break;
  83. case 2: surname = linia; break;
  84. case 3: PIN = atoi(linia.c_str()); break;
  85. }
  86. nr_linii++;
  87. }
  88.  
  89. plik.close();
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement