Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <cstdio>
  5.  
  6. using namespace std;
  7.  
  8. void input();
  9. void searchname();
  10. void searchrezyser();
  11. void searchsalary();
  12. void quit();
  13. void displayall();
  14. void search();
  15. void deleteFile();
  16. void editFile();
  17.  
  18. int main()
  19. {
  20.  
  21. int choice;
  22. cout << "1.Dodaj nowy film" << endl;
  23. cout << "2.Wyszukaj film" << endl;
  24. cout << "3.Wyczysc baze" << endl;
  25. cout << "4.Edytuj film" << endl;
  26. cout << "5.Zamknij Program" << endl;
  27. cout << "SLOWA ODDZIELAJ _" << endl;
  28. cin >> choice;
  29.  
  30. switch (choice){
  31. case 1:
  32. input();
  33. break;
  34. case 2:
  35. search();
  36. break;
  37. case 3:
  38. deleteFile();
  39. break;
  40. case 4:
  41. editFile();
  42. break;
  43. case 5:
  44. quit();
  45. break;
  46.  
  47. cin.get();
  48.  
  49.  
  50. }
  51. }
  52. void editFile()
  53. {
  54. string tytul, input, newTytul,decision, gatunek;
  55. string rezyser, newRezyser;
  56. int choice3, newChoice3;
  57. ifstream employee("newemployee.txt");
  58. if (!employee.eof()){
  59. employee >> tytul >> rezyser >> gatunek >> choice3;
  60. }
  61.  
  62. cout << "Wprowadz tytul filmu:";
  63. cin >> input;
  64.  
  65. if (input == tytul)
  66. {
  67.  
  68. cout << tytul << " | " << rezyser << " | " << choice3 << endl;
  69. cout << "Czy tytul jest poprawny[y][n]:";
  70. cin >> decision;
  71. if (decision == "y"){
  72. cout << "Podaj nowy tytul:";
  73. cin >> newTytul;
  74. tytul = newTytul;
  75.  
  76. cout << "Podaj nowego rezysera:";
  77. cin >> newRezyser;
  78. rezyser = newRezyser;
  79.  
  80. cout << "Podaj gatunek filmu";
  81. cin >> gatunek;
  82.  
  83. cout << "Oznacz jako:";
  84. cin >> newChoice3;
  85.  
  86. switch (newChoice3){
  87. case 1:
  88. cout << "Obejrzane" << endl;
  89. break;
  90. case 2:
  91. cout << "W trakcie" << endl;
  92. break;
  93. case 3:
  94. cout << "Nieobejrzane" << endl;
  95. break;
  96. case 4:
  97. cout << "Do obejrzenia" << endl;
  98. break;
  99. }
  100. choice3 = newChoice3;
  101.  
  102. }
  103.  
  104. employee.close();
  105. }
  106.  
  107. ofstream employee2("newemployee.txt", ios::app);
  108. employee2 << tytul << ' ' << rezyser << ' ' << gatunek << ' ' << choice3 << endl;
  109. employee2.close();
  110.  
  111. main();
  112. }
  113.  
  114. void input()
  115. {
  116. int choice3;
  117. string tytul;
  118. string rezyser, gatunek;
  119.  
  120.  
  121. ofstream newemployee("newemployee.txt", ios::app);
  122.  
  123. cout << "Wprowadz tytul nowego filmu" << endl;
  124. cin >> tytul;
  125. cin.sync();
  126.  
  127. cout << "Wprowadz rezysera filmu." << endl;
  128. cin >> rezyser;
  129.  
  130. cout << "Podaj gatunek filmu" << endl;
  131. cin >> gatunek;
  132.  
  133. cout << "Oznacz jako:" << endl;
  134.  
  135. cout << "1. Obejrzane" << endl;
  136. cout << "2. W trakcie" << endl;
  137. cout << "3. Nieobejrzane" << endl;
  138. cout << "4. Do obejrzenia" << endl;
  139.  
  140. cin >> choice3;
  141.  
  142. switch (choice3){
  143. case 1:
  144. cout << "Obejrzane" << endl;
  145. break;
  146. case 2:
  147. cout << "W trakcie" << endl;
  148. break;
  149. case 3:
  150. cout << "Nieobejrzane" << endl;
  151. break;
  152. case 4:
  153. cout << "Do obejrzenia" << endl;
  154. break;
  155. }
  156.  
  157. newemployee << tytul << ' ' << rezyser << ' ' << gatunek << ' ' << choice3 << ' ' << endl;
  158. newemployee.close();
  159. main();
  160. }
  161. void searchname()
  162. {
  163. ifstream employee("newemployee.txt");
  164. string tytul;
  165. string str, line;
  166. string rezyser, gatunek;
  167. int offset;
  168. int choice3;
  169.  
  170. cout << "Podaj tytul filmu:" << endl;
  171. cin >> str;
  172.  
  173. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  174. if (str == tytul){
  175.  
  176. cout << "Film znaleziony" << endl;
  177. cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
  178. cout << "---------------------" << endl;
  179. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " <<choice3 << endl;
  180. }
  181. }
  182.  
  183.  
  184. while (employee >> tytul ){
  185. if (str != tytul){
  186.  
  187. cout << "Brak filmu w bazie" << endl;
  188.  
  189. }
  190. }
  191.  
  192. main();
  193.  
  194.  
  195. }
  196. void searchrezyser()
  197. {
  198. ifstream employee("newemployee.txt");
  199. string tytul, gatunek;
  200. string rezyser ;
  201. string frezyser;
  202. int choice3;
  203.  
  204. cout << "Podaj rezysera filmu:" << endl;
  205. cin >> frezyser;
  206. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  207. if (frezyser == rezyser){
  208.  
  209. cout << "Film znaleziony" << endl;
  210. cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
  211. cout << "-------------------------" << endl;
  212. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
  213. }
  214. }
  215. while (employee >> rezyser){
  216. if (frezyser != rezyser){
  217.  
  218. cout << "Brak filmu w bazie"<< endl;
  219.  
  220.  
  221. }
  222. }
  223.  
  224. cin.get();
  225. main();
  226. }
  227.  
  228. void searchgatunek()
  229. {
  230. ifstream employee("newemployee.txt");
  231. string tytul, gatunek;
  232. string rezyser ;
  233. string fgatunek;
  234. int choice3;
  235.  
  236. cout << "Podaj gatunek filmu:" << endl;
  237. cin >> fgatunek;
  238. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  239. if (fgatunek == gatunek){
  240.  
  241. cout << "Film znaleziony" << endl;
  242. cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
  243. cout << "-------------------------" << endl;
  244. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
  245. }
  246. }
  247. while (employee >> gatunek){
  248. if (fgatunek != gatunek){
  249.  
  250. cout << "Brak filmu w bazie"<< endl;
  251.  
  252.  
  253. }
  254. }
  255.  
  256. cin.get();
  257. main();
  258. }
  259.  
  260. void searchoznaczenie()
  261. {
  262. ifstream employee ("newemployee.txt");
  263. string tytul;
  264. string rezyser, gatunek;
  265. int choice3;
  266. int fchoice3;
  267.  
  268. cout << "Podaj oznaczenie filmu:" << endl;
  269. cout << "1. Obejrzane" << endl;
  270. cout << "2. W trakcie" << endl;
  271. cout << "3. Nieobejrzane" << endl;
  272. cout << "4. Do obejrzenia" << endl;
  273. cin >> fchoice3;
  274.  
  275. switch (choice3){
  276. case 1:
  277. cout << "Obejrzane" << endl;
  278. break;
  279. case 2:
  280. cout << "W trakcie" << endl;
  281. break;
  282. case 3:
  283. cout << "Nieobejrzane" << endl;
  284. break;
  285. case 4:
  286. cout << "Do obejrzenia" << endl;
  287. break;
  288. }
  289.  
  290. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  291. if (fchoice3 == choice3 ){
  292.  
  293. cout << "Film znaleziony"<< endl;
  294. cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
  295. cout << "-------------------------" << endl;
  296. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " <<choice3 << endl;
  297.  
  298. }
  299. }
  300. while (employee >> choice3){
  301. if (fchoice3 != choice3){
  302.  
  303. cout << "Brak filmu w bazie" << endl;
  304. }
  305. }
  306.  
  307. cin.get();
  308. main();
  309. }
  310. void quit()
  311. {
  312.  
  313. cin.get();
  314. }
  315.  
  316. void displayall()
  317. {
  318. ifstream employee("newemployee.txt");
  319. string tytul, gatunek;
  320. string rezyser ;
  321. int choice3;
  322.  
  323. cout << "tytul" << " | " << "rezyser" << " | " << "gatunek" << " | " << "oznaczenie" << endl;
  324. cout << "---------------------------------------" << endl;
  325. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  326. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
  327. }
  328.  
  329. cin.get();
  330. main();
  331. }
  332.  
  333. void search()
  334. {
  335. string rezyser;
  336. string tytul;
  337. int choice3;
  338. int choice2;
  339.  
  340.  
  341. cout << "1.Szukaj po tytule" << endl;
  342. cout << "2.Szukaj po rezyserze" << endl;
  343. cout << "3.Szukaj po gatunku" << endl;\
  344. cout << "4.Szukaj po oznaczeniu" << endl;
  345. cout << "5.Wyswietl wszystkie filmy" << endl;
  346. cout << "6.Back" << endl;
  347. cout << "7.Exit program" << endl;
  348. cin >> choice2;
  349.  
  350. switch (choice2){
  351. case 1:
  352. searchname();
  353. break;
  354. case 2:
  355. searchrezyser();
  356. break;
  357. case 3:
  358. searchgatunek();
  359. break;
  360. case 4:
  361. searchoznaczenie();
  362. break;
  363. case 5:
  364. displayall();
  365. break;
  366. case 6:
  367. main();
  368. break;
  369. case 7:
  370. quit();
  371. break;
  372. }
  373.  
  374.  
  375.  
  376.  
  377. }
  378. void deleteFile()
  379. {
  380.  
  381. string decision;
  382. cout << "Czy na pewno[Y]es[N]o" << endl;
  383. cin >> decision;
  384. if (decision == "y"){
  385. ofstream employee("newemployee.txt");
  386.  
  387. cout << "Filmy usuniete!" << endl;
  388.  
  389. employee.close();
  390. main();
  391. }
  392. else{
  393. main();
  394. }
  395. }
  396.  
  397. /*
  398. void editOznaczenie()
  399. {
  400. string tytul, input ,decision, gatunek;
  401. string rezyser, to_string;
  402. int choice3;
  403. ifstream employee("newemployee.txt");
  404. cout << "Podaj tytul filmu ktorego oznaczenie chcesz zmienic:";
  405. cin >> tytul;
  406. string tytul2 = to_string(tytul);
  407. tytul2.append(".txt");
  408. ifstream employee(tytul2);
  409. while (employee >> tytul >> rezyser >> gatunek >> choice3){
  410. cout << tytul << " | "<< rezyser << " | " << gatunek << " | " << choice3 << endl;
  411. }
  412. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement