Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <cstdio>
- using namespace std;
- void input();
- void searchname();
- void searchrezyser();
- void searchsalary();
- void quit();
- void displayall();
- void search();
- void deleteFile();
- void editFile();
- int main()
- {
- int choice;
- cout << "1.Dodaj nowy film" << endl;
- cout << "2.Wyszukaj film" << endl;
- cout << "3.Wyczysc baze" << endl;
- cout << "4.Edytuj film" << endl;
- cout << "5.Zamknij Program" << endl;
- cout << "SLOWA ODDZIELAJ _" << endl;
- cin >> choice;
- switch (choice){
- case 1:
- input();
- break;
- case 2:
- search();
- break;
- case 3:
- deleteFile();
- break;
- case 4:
- editFile();
- break;
- case 5:
- quit();
- break;
- cin.get();
- }
- }
- void editFile()
- {
- string tytul, input, newTytul,decision, gatunek;
- string rezyser, newRezyser;
- int choice3, newChoice3;
- ifstream employee("newemployee.txt");
- if (!employee.eof()){
- employee >> tytul >> rezyser >> gatunek >> choice3;
- }
- cout << "Wprowadz tytul filmu:";
- cin >> input;
- if (input == tytul)
- {
- cout << tytul << " | " << rezyser << " | " << choice3 << endl;
- cout << "Czy tytul jest poprawny[y][n]:";
- cin >> decision;
- if (decision == "y"){
- cout << "Podaj nowy tytul:";
- cin >> newTytul;
- tytul = newTytul;
- cout << "Podaj nowego rezysera:";
- cin >> newRezyser;
- rezyser = newRezyser;
- cout << "Podaj gatunek filmu";
- cin >> gatunek;
- cout << "Oznacz jako:";
- cin >> newChoice3;
- switch (newChoice3){
- case 1:
- cout << "Obejrzane" << endl;
- break;
- case 2:
- cout << "W trakcie" << endl;
- break;
- case 3:
- cout << "Nieobejrzane" << endl;
- break;
- case 4:
- cout << "Do obejrzenia" << endl;
- break;
- }
- choice3 = newChoice3;
- }
- employee.close();
- }
- ofstream employee2("newemployee.txt", ios::app);
- employee2 << tytul << ' ' << rezyser << ' ' << gatunek << ' ' << choice3 << endl;
- employee2.close();
- main();
- }
- void input()
- {
- int choice3;
- string tytul;
- string rezyser, gatunek;
- ofstream newemployee("newemployee.txt", ios::app);
- cout << "Wprowadz tytul nowego filmu" << endl;
- cin >> tytul;
- cin.sync();
- cout << "Wprowadz rezysera filmu." << endl;
- cin >> rezyser;
- cout << "Podaj gatunek filmu" << endl;
- cin >> gatunek;
- cout << "Oznacz jako:" << endl;
- cout << "1. Obejrzane" << endl;
- cout << "2. W trakcie" << endl;
- cout << "3. Nieobejrzane" << endl;
- cout << "4. Do obejrzenia" << endl;
- cin >> choice3;
- switch (choice3){
- case 1:
- cout << "Obejrzane" << endl;
- break;
- case 2:
- cout << "W trakcie" << endl;
- break;
- case 3:
- cout << "Nieobejrzane" << endl;
- break;
- case 4:
- cout << "Do obejrzenia" << endl;
- break;
- }
- newemployee << tytul << ' ' << rezyser << ' ' << gatunek << ' ' << choice3 << ' ' << endl;
- newemployee.close();
- main();
- }
- void searchname()
- {
- ifstream employee("newemployee.txt");
- string tytul;
- string str, line;
- string rezyser, gatunek;
- int offset;
- int choice3;
- cout << "Podaj tytul filmu:" << endl;
- cin >> str;
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- if (str == tytul){
- cout << "Film znaleziony" << endl;
- cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
- cout << "---------------------" << endl;
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " <<choice3 << endl;
- }
- }
- while (employee >> tytul ){
- if (str != tytul){
- cout << "Brak filmu w bazie" << endl;
- }
- }
- main();
- }
- void searchrezyser()
- {
- ifstream employee("newemployee.txt");
- string tytul, gatunek;
- string rezyser ;
- string frezyser;
- int choice3;
- cout << "Podaj rezysera filmu:" << endl;
- cin >> frezyser;
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- if (frezyser == rezyser){
- cout << "Film znaleziony" << endl;
- cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
- cout << "-------------------------" << endl;
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
- }
- }
- while (employee >> rezyser){
- if (frezyser != rezyser){
- cout << "Brak filmu w bazie"<< endl;
- }
- }
- cin.get();
- main();
- }
- void searchgatunek()
- {
- ifstream employee("newemployee.txt");
- string tytul, gatunek;
- string rezyser ;
- string fgatunek;
- int choice3;
- cout << "Podaj gatunek filmu:" << endl;
- cin >> fgatunek;
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- if (fgatunek == gatunek){
- cout << "Film znaleziony" << endl;
- cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
- cout << "-------------------------" << endl;
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
- }
- }
- while (employee >> gatunek){
- if (fgatunek != gatunek){
- cout << "Brak filmu w bazie"<< endl;
- }
- }
- cin.get();
- main();
- }
- void searchoznaczenie()
- {
- ifstream employee ("newemployee.txt");
- string tytul;
- string rezyser, gatunek;
- int choice3;
- int fchoice3;
- cout << "Podaj oznaczenie filmu:" << endl;
- cout << "1. Obejrzane" << endl;
- cout << "2. W trakcie" << endl;
- cout << "3. Nieobejrzane" << endl;
- cout << "4. Do obejrzenia" << endl;
- cin >> fchoice3;
- switch (choice3){
- case 1:
- cout << "Obejrzane" << endl;
- break;
- case 2:
- cout << "W trakcie" << endl;
- break;
- case 3:
- cout << "Nieobejrzane" << endl;
- break;
- case 4:
- cout << "Do obejrzenia" << endl;
- break;
- }
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- if (fchoice3 == choice3 ){
- cout << "Film znaleziony"<< endl;
- cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
- cout << "-------------------------" << endl;
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " <<choice3 << endl;
- }
- }
- while (employee >> choice3){
- if (fchoice3 != choice3){
- cout << "Brak filmu w bazie" << endl;
- }
- }
- cin.get();
- main();
- }
- void quit()
- {
- cin.get();
- }
- void displayall()
- {
- ifstream employee("newemployee.txt");
- string tytul, gatunek;
- string rezyser ;
- int choice3;
- cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
- cout << "---------------------------------------" << endl;
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
- }
- cin.get();
- main();
- }
- void search()
- {
- string rezyser;
- string tytul;
- int choice3;
- int choice2;
- cout << "1.Szukaj po tytule" << endl;
- cout << "2.Szukaj po rezyserze" << endl;
- cout << "3.Szukaj po gatunku" << endl;\
- cout << "4.Szukaj po oznaczeniu" << endl;
- cout << "5.Wyswietl wszystkie filmy" << endl;
- cout << "6.Back" << endl;
- cout << "7.Exit program" << endl;
- cin >> choice2;
- switch (choice2){
- case 1:
- searchname();
- break;
- case 2:
- searchrezyser();
- break;
- case 3:
- searchgatunek();
- break;
- case 4:
- searchoznaczenie();
- break;
- case 5:
- displayall();
- break;
- case 6:
- main();
- break;
- case 7:
- quit();
- break;
- }
- }
- void deleteFile()
- {
- string decision;
- cout << "Czy na pewno[Y]es[N]o" << endl;
- cin >> decision;
- if (decision == "y"){
- ofstream employee("newemployee.txt");
- cout << "Filmy usuniete!" << endl;
- employee.close();
- main();
- }
- else{
- main();
- }
- }
- /*
- void editOznaczenie()
- {
- string tytul, input ,decision, gatunek;
- string rezyser, to_string;
- int choice3;
- ifstream employee("newemployee.txt");
- cout << "Podaj tytul filmu ktorego oznaczenie chcesz zmienic:";
- cin >> tytul;
- string tytul2 = to_string(tytul);
- tytul2.append(".txt");
- ifstream employee(tytul2);
- while (employee >> tytul >> rezyser >> gatunek >> choice3){
- cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement