Advertisement
Guest User

Untitled

a guest
Dec 31st, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <conio.h>
  4. #include <fstream>
  5. #include <sstream>
  6. #include <stdio.h>
  7. #include "naglowki.h"
  8.  
  9. using namespace std;
  10.  
  11. void Klient::notatka()
  12. {
  13.     char wybor;
  14.  
  15.     while(true)
  16.     {
  17.         system("cls");
  18.  
  19.         cout << " ===== NOTATKI =====" << endl << endl;
  20.  
  21.         cout << "1. Pokaz notatki" << endl;
  22.         cout << "2. Dodaj notatke" << endl;
  23.         cout << "3. Usun notatke" << endl << endl;
  24.         cout << "0. Wyjscie" << endl << endl;
  25.  
  26.         wybor = getch();
  27.  
  28.         if(wybor == '0')
  29.             break;
  30.  
  31.         switch(wybor)
  32.         {
  33.         case '1':
  34.             {
  35.                 //pokaz_notatki();
  36.                 break;
  37.             }
  38.         case '2':
  39.             {
  40.                 dodaj_notatke();
  41.                 break;
  42.             }
  43.         case '3':
  44.             {
  45.                 //usun_notatke();
  46.                 break;
  47.             }
  48.         default:
  49.             {
  50.                 cout << endl;
  51.  
  52.                 cout << "Podaj prawidlowy wybor!";
  53.                 Sleep(2000);
  54.             }
  55.         }
  56.     }
  57. }
  58.  
  59. void Klient::pokaz_notatki()
  60. {
  61.     char wybor;
  62.  
  63.     fstream plik;
  64.  
  65.     while(true)
  66.     {
  67.         system("cls");
  68.  
  69.         cout << "===== NOTATKI =====" << endl << endl;
  70.  
  71.  
  72.     }
  73. }
  74.  
  75. void Klient::dodaj_notatke()
  76. {
  77.     char wybor;
  78.  
  79.     fstream plik;
  80.  
  81.     ostringstream ss;
  82.     ss << _PIN;
  83.     string stringPIN = ss.str();
  84.     ss.str("");
  85.  
  86.     string nazwa, tresc, format;
  87.  
  88.     cin.clear();
  89.     cin.sync();
  90.  
  91.     system("cls");
  92.  
  93.     cout << "Podaj nazwe notatki: ";
  94.     getline(cin, nazwa);
  95.  
  96.     cout << endl;
  97.  
  98.     cout << "Podaj tresc notatki: ";
  99.     getline(cin, tresc);
  100.  
  101.     cout << endl << endl;
  102.  
  103.     CreateDirectory(("NOTATKI/" + stringPIN).c_str(), NULL);
  104.  
  105.     while(true)
  106.     {
  107.         system("cls");
  108.  
  109.         cout << "Format: " << endl << endl;
  110.         cout << "1. TXT" << endl;
  111.         cout << "2. DOC" << endl << endl;
  112.  
  113.         wybor = getch();
  114.  
  115.         switch(wybor)
  116.         {
  117.         case '1':
  118.             {
  119.                 plik.open(("NOTATKI/" + stringPIN + "/" + nazwa + ".txt").c_str(), ios::out);
  120.                 format = ".txt";
  121.                 break;
  122.             }
  123.         case '2':
  124.             {
  125.                 plik.open(("NOTATKI/" + stringPIN + "/" + nazwa + ".doc").c_str(), ios::out);
  126.                 format = ".doc";
  127.                 break;
  128.             }
  129.         default:
  130.             {
  131.                 system("cls");
  132.  
  133.                 cout << "Podaj prawidlowy wybor!";
  134.                 Sleep(2000);
  135.  
  136.                 continue;
  137.             }
  138.         }
  139.  
  140.         plik << tresc;
  141.         cout << endl << endl << "Stworzono notatke '" << nazwa << "' w formacie " << format << " ...";
  142.  
  143.         Sleep(3000);
  144.  
  145.         break;
  146.     }
  147.  
  148.     plik.close();
  149.     plik.clear();
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement