Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <conio.h>
- #include <fstream>
- #include <sstream>
- #include <stdio.h>
- #include "naglowki.h"
- using namespace std;
- void Klient::notatka()
- {
- char wybor;
- while(true)
- {
- system("cls");
- cout << " ===== NOTATKI =====" << endl << endl;
- cout << "1. Pokaz notatki" << endl;
- cout << "2. Dodaj notatke" << endl;
- cout << "3. Usun notatke" << endl << endl;
- cout << "0. Wyjscie" << endl << endl;
- wybor = getch();
- if(wybor == '0')
- break;
- switch(wybor)
- {
- case '1':
- {
- //pokaz_notatki();
- break;
- }
- case '2':
- {
- dodaj_notatke();
- break;
- }
- case '3':
- {
- //usun_notatke();
- break;
- }
- default:
- {
- cout << endl;
- cout << "Podaj prawidlowy wybor!";
- Sleep(2000);
- }
- }
- }
- }
- void Klient::pokaz_notatki()
- {
- char wybor;
- fstream plik;
- while(true)
- {
- system("cls");
- cout << "===== NOTATKI =====" << endl << endl;
- }
- }
- void Klient::dodaj_notatke()
- {
- char wybor;
- fstream plik;
- ostringstream ss;
- ss << _PIN;
- string stringPIN = ss.str();
- ss.str("");
- string nazwa, tresc, format;
- cin.clear();
- cin.sync();
- system("cls");
- cout << "Podaj nazwe notatki: ";
- getline(cin, nazwa);
- cout << endl;
- cout << "Podaj tresc notatki: ";
- getline(cin, tresc);
- cout << endl << endl;
- CreateDirectory(("NOTATKI/" + stringPIN).c_str(), NULL);
- while(true)
- {
- system("cls");
- cout << "Format: " << endl << endl;
- cout << "1. TXT" << endl;
- cout << "2. DOC" << endl << endl;
- wybor = getch();
- switch(wybor)
- {
- case '1':
- {
- plik.open(("NOTATKI/" + stringPIN + "/" + nazwa + ".txt").c_str(), ios::out);
- format = ".txt";
- break;
- }
- case '2':
- {
- plik.open(("NOTATKI/" + stringPIN + "/" + nazwa + ".doc").c_str(), ios::out);
- format = ".doc";
- break;
- }
- default:
- {
- system("cls");
- cout << "Podaj prawidlowy wybor!";
- Sleep(2000);
- continue;
- }
- }
- plik << tresc;
- cout << endl << endl << "Stworzono notatke '" << nazwa << "' w formacie " << format << " ...";
- Sleep(3000);
- break;
- }
- plik.close();
- plik.clear();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement