Guest User

rapsheet

a guest
Jul 12th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.47 KB | None | 0 0
  1. #include<fstream.h>
  2. #include<stdio.h>
  3. #include<string.h>
  4. #include<conio.h>
  5. #include<stdlib.h>
  6.  
  7. void clear_recent();
  8. void recent();
  9. void login_menu();
  10. void login();
  11. void change();
  12. void main_menu();
  13. void mainmenu3();
  14. void create_record();
  15. void read_record();
  16. void search();
  17. void modify();
  18. void Delete();
  19. void add_car();
  20. void add_inf();
  21. void delete_car();
  22. void delete_inf();
  23. void display_car();
  24. void display_inf();
  25. void delay(long);
  26. void CreateAniline(int,long);
  27.  
  28. char pass[30];
  29. long delay_time=100000;
  30.  
  31. class crimdata
  32. {
  33. int code;
  34. char fname[30];
  35. char lname[30];
  36. long cost_to_state;
  37. long fines_due;
  38. long bounty;
  39. char casehistory[500];
  40. public:
  41. void getd();
  42. void putd();
  43. int getcode();
  44. long getbounty();
  45. long getfines();
  46. long getcst();
  47. char* getfirstname();
  48. char* getlastname();
  49. char* getcasehistory();
  50. }c;
  51.  
  52. crimdata stmp;
  53.  
  54. long crimdata::getbounty()
  55. {
  56. return bounty;
  57. }
  58.  
  59. long crimdata::getfines()
  60. {
  61. return fines_due;
  62. }
  63.  
  64. long crimdata::getcst()
  65. {
  66. return cost_to_state;
  67. }
  68.  
  69. char* crimdata::getfirstname()
  70. {
  71. return fname;
  72. }
  73.  
  74. char* crimdata::getlastname()
  75. {
  76. return lname;
  77. }
  78.  
  79. char* crimdata::getcasehistory()
  80. {
  81. return casehistory;
  82. }
  83.  
  84. void crimdata::getd()
  85. {
  86. cout<<"\nENTER CRIMINAL CODE:\n";
  87. cin>>code;
  88.  
  89. cout<<"\nENTER CRIMINAL'S FIRST NAME:\n";
  90. gets(fname);
  91.  
  92. cout<<"\nENTER CRIMINAL'S LAST NAME:\n";
  93. gets(lname);
  94.  
  95. cout<<"\nENTER COST TO STATE:\n";
  96. cin>>cost_to_state;
  97.  
  98. cout<<"\nENTER FINES DUE:\n";
  99. cin>>fines_due;
  100.  
  101. cout<<"\nENTER BOUNTY:\n";
  102. cin>>bounty;
  103.  
  104. cout<<"\nENTER CASE HISTORY:\n";
  105. gets(casehistory);
  106. }
  107.  
  108. void crimdata::putd()
  109. {
  110. cout<<code<<"\t\t\t"<<fname<<" "<<lname<<"\t\t\t"<<bounty<<endl;
  111. }
  112.  
  113. int crimdata::getcode()
  114. {
  115. return code;
  116. }
  117.  
  118. class infractions
  119. {
  120. char category[50];
  121. int no_of_times;
  122. public:
  123. void getd();
  124. void putd();
  125. char* getiname();
  126. }i;
  127.  
  128. void infractions::getd()
  129. {
  130. cout<<"\nENTER INFRACTION CATEGORY CAUSED BY CRIMINAL:\n";
  131. gets(category);
  132.  
  133. cout<<"\nENTER THE NO. OF TIMES THE CRIMINAL HAS CAUSED THE INFRACTION:\n";
  134. cin>>no_of_times;
  135. }
  136.  
  137. void infractions::putd()
  138. {
  139. cout<<category<<"\t\t\t\t"<<no_of_times<<endl;
  140. }
  141.  
  142. char* infractions::getiname()
  143. {
  144. return category;
  145. }
  146.  
  147. class vehicle
  148. {
  149. char name[30];
  150. int impound_strike;
  151. public:
  152. void getd();
  153. void putd();
  154. char* getvname();
  155. }v;
  156.  
  157. void vehicle::getd()
  158. {
  159. cout<<"\nENTER VEHICLE NAME USED BY CRIMINAL:\n";
  160. gets(name);
  161.  
  162. cout<<"\nENTER THE NO. OF IMPOUND STRIKES:\n";
  163. cin>>impound_strike;
  164. }
  165.  
  166. void vehicle::putd()
  167. {
  168. cout<<name<<"\t\t\t\t"<<impound_strike<<endl;
  169. }
  170.  
  171. char* vehicle::getvname()
  172. {
  173. return name;
  174. }
  175. void login_menu()
  176. {
  177. char str[30];
  178. strcpy(str,"DELHI POLICE DEPARTMENT");
  179. int c,l;
  180. l=strlen(str);
  181. cout<<"\n\n\n";
  182. cout<<"\t - - - - - - - - - - - - - - \n";
  183. cout<<"\t - - - - - - - - - - - - - - - - \n";
  184. cout<<"\t - - - - - - - - - - - - \n";
  185. cout<<"\t - - - - - - - - - - - - - - \n";
  186. cout<<"\t - - - - - - - - - - - - - \n";
  187. cout<<"\t - - - - - - - - - - \n";
  188. cout<<"\t - - - - - - - - - - - \n";
  189. cout<<"\t - - - - o - - o - - - - \n";
  190. cout<<"\n\t ";
  191. for(int i=0;i<=l;i++)
  192. {
  193. cout<<str[i];
  194. delay(delay_time*4);
  195. }
  196. cout<<endl;
  197. cout<<"\n\t\t\t 1. LOGIN";
  198. cout<<"\n\t\t\t 2. CHANGE PASSWORD";
  199. cout<<"\n\t\t\t 3. EXIT\n";
  200. cout<<"\n\t\t\tENTER YOUR CHOICE:";
  201. cin>>c;
  202. if(c==1)
  203. {
  204. clrscr();
  205. login();
  206. }
  207. else if(c==2)
  208. {
  209. clrscr();
  210. change();
  211. }
  212. else if(c==3)
  213. exit(0);
  214. else
  215. {
  216. clrscr();
  217. cout<<"\n\n\n\n\t\t\t!!INVALID CHOICE!! ";
  218. getche();
  219. clrscr();
  220. login_menu();
  221. }
  222. }
  223.  
  224. void login()
  225. {
  226. clrscr();
  227. char p[30];
  228. int c;
  229. cout<<"\n\n\n\n\n\t\t\t PASSCODE: ";
  230. int t=0;
  231. char ch;
  232.  
  233. while(ch!=13)
  234. {
  235. ch=getch();
  236. if(ch==8)
  237. {
  238. clrscr();
  239. cout<<"\n\n\n\n\n\t\t\t PASSCODE: ";
  240. t=t-1;
  241. for(int i=0;i<t;i++)
  242. {
  243. cout<<"*";
  244. }
  245. p[t]='\0';
  246. }
  247. else
  248. {
  249. p[t]=ch;
  250. cout<<"*";
  251. t++;
  252. }
  253. }
  254. p[t-1]='\0';
  255.  
  256.  
  257. ifstream fin("pass.dat",ios::binary);
  258. fin.getline(pass,30);
  259. fin.close();
  260. if(strcmp(p,pass)==0)
  261. {
  262. clrscr();
  263. char str[30];
  264. int l;
  265. strcpy(str,"LOGIN SUCCESSFULL");
  266. l = strlen(str);
  267. cout<<"\n\n\n\n\n\n\t\t\t ";
  268. for(int i=0;i<=l;i++)
  269. {
  270. cout<<str[i];
  271. delay(delay_time*4);
  272. }
  273. cout<<endl;
  274. getche();
  275. clrscr();
  276. main_menu();
  277. }
  278. else
  279. {
  280. clrscr();
  281. selection:
  282. cout<<"\n\t\t\t!! WRONG PASSCODE !!\n";
  283. cout<<"\n\t\t\tWANT TO TRY AGAIN???\n";
  284. cout<<"\n\t\t\t 1. YES ";
  285. cout<<"\n\t\t\t 2. NO ";
  286. cout<<"\n\n\t\t\tENTER YOUR CHOICE:";
  287. cin>>c;
  288. if(c==1)
  289. {
  290. clrscr();
  291. login();
  292. }
  293. else if(c==2)
  294. {
  295. clrscr();
  296. login_menu();
  297. }
  298. else
  299. {
  300. clrscr();
  301. cout<<"\n\n\n\n\t\t\tINVALID CHOICE...ENTER A VALID CHOICE!!\n";
  302. getche();
  303. clrscr();
  304. goto selection;
  305. }
  306. }
  307. }
  308.  
  309.  
  310. void change()
  311. {
  312. int c;
  313. char tmp[30];
  314. clrscr();
  315. cout<<"\nENTER CURRENT PASSWORD:";
  316. int t=0;
  317. char ch;
  318. while(ch!=13)
  319. {
  320. ch=getch();
  321. if(ch==8)
  322. {
  323. clrscr();
  324. cout<<"\nENTER CURRENT PASSWORD:";
  325. t=t-1;
  326. for(int i=0;i<t;i++)
  327. {
  328. cout<<"*";
  329. }
  330. tmp[t]='\0';
  331. }
  332. else
  333. {
  334. tmp[t]=ch;
  335. cout<<"*";
  336. t++;
  337. }
  338. }
  339. tmp[t-1]='\0';
  340.  
  341. ifstream fin("pass.dat",ios::binary);
  342. fin.getline(pass,30);
  343. fin.close();
  344. if(strcmp(pass,tmp)==0)
  345. {
  346. t=0;
  347. clrscr();
  348. cout<<"\nENTER NEW PASSWORD:";
  349.  
  350. ch=0;
  351. while(ch!=13)
  352. {
  353. ch=getch();
  354. if(ch==8)
  355. {
  356. clrscr();
  357. cout<<"\nENTER NEW PASSWORD:";
  358. t=t-1;
  359. for(int i=0;i<t;i++)
  360. {
  361. cout<<"*";
  362. }
  363. tmp[t]='\0';
  364. }
  365. else
  366. {
  367. tmp[t]=ch;
  368. cout<<"*";
  369. t++;
  370. }
  371. }
  372. tmp[t-1]='\0';
  373.  
  374.  
  375. strcpy(pass,tmp);
  376. int l=strlen(pass);
  377. ofstream fout("pass.dat",ios::binary|ios::trunc);
  378. for(int i=0;i<=l;i++)
  379. {
  380. fout.put(pass[i]);
  381. }
  382. fout.close();
  383. cout<<"\n!!PASSWORD CHANGED SUCCESSFULLY!!";
  384. getche();
  385. clrscr();
  386. login_menu();
  387. }
  388. else
  389. {
  390. selection2:
  391. clrscr();
  392. cout<<"\nWRONG CURRENT PASSWORD";
  393. cout<<"\nWANT TO TRY AGAIN?\n";
  394. cout<<"\n1.YES\n";
  395. cout<<"\n2.NO \n";
  396. cout<<"\nENTER YOUR CHOICE:";
  397. cin>>c;
  398. if(c==1)
  399. {
  400. clrscr();
  401. change();
  402. }
  403. else if(c==2)
  404. {
  405. clrscr();
  406. login_menu();
  407. }
  408. else
  409. {
  410. clrscr();
  411. cout<<"\n\n\n\t\t\tINVALID CHOICE...ENTER A VALID ONE!!";
  412. getche();
  413. clrscr();
  414. goto selection2;
  415. }
  416. }
  417. }
  418.  
  419. void main_menu()
  420. {
  421. int ch;
  422. cout<<"\t _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n";
  423. cout<<"\t _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n";
  424. cout<<"\t _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n";
  425. cout<<"\t _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n";
  426. cout<<"\t _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n";
  427. cout<<"\n\t\t\t1. CREATE NEW CRIMINAL RECORD";
  428. cout<<"\n\t\t\t2. DISPLAY ALL CRIMINAL RECORDS";
  429. cout<<"\n\t\t\t3. DISPLAY RECENTLY OPENED PROFILES";
  430. cout<<"\n\t\t\t4. ENTER INTO CRIMINAL PROFILE";
  431. cout<<"\n\t\t\t5. MODIFY EXISTING RECORD";
  432. cout<<"\n\t\t\t6. REMOVE EXISTING RECORD";
  433. cout<<"\n\t\t\t7. CLEAR RECENTLY OPENED PROFILES";
  434. cout<<"\n\t\t\t8. LOGOUT";
  435. cout<<"\n\t\t\tENTER YOUR CHOICE:";
  436. cin>>ch;
  437. if(ch==1)
  438. {
  439. clrscr();
  440. create_record();
  441. }
  442. else if(ch==2)
  443. {
  444. clrscr();
  445. read_record();
  446. }
  447. else if(ch==3)
  448. {
  449. clrscr();
  450. recent();
  451. }
  452. else if(ch==4)
  453. {
  454. clrscr();
  455. search();
  456. }
  457. else if(ch==5)
  458. {
  459. clrscr();
  460. modify();
  461. }
  462. else if(ch==6)
  463. {
  464. clrscr();
  465. Delete();
  466. }
  467. else if(ch==7)
  468. {
  469. clrscr();
  470. clear_recent();
  471. cout<<"\n\n\n\n\t\t\t HISTORY CLEARED SUCCESSFULLY!! ";
  472. getche();
  473. clrscr();
  474. main_menu();
  475. }
  476. else if(ch==8)
  477. {
  478. clrscr();
  479. login_menu();
  480. }
  481. else
  482. {
  483. cout<<"\nINVALID CHOICE\n";
  484. getche();
  485. clrscr();
  486. main_menu();
  487. }
  488. }
  489.  
  490.  
  491. void create_record()
  492. {
  493. clrscr();
  494. char inf[30];
  495. char car[30];
  496. ofstream afile("Main.rap",ios::binary|ios::app);
  497. c.getd();
  498. afile.write((char*)&c,sizeof(c));
  499. afile.close();
  500. cout<<"\nRECORD CREATED SUCCESSFULLY\n";
  501. getche();
  502. clrscr();
  503. main_menu();
  504. }
  505.  
  506. void read_record()
  507. {
  508. clrscr();
  509. ifstream bfile("MAIN.rap",ios::binary);
  510. cout<<"CODE\t\t\tNAME\t\t\t\tBOUNTY\n";
  511. while(bfile.read((char*)&c, sizeof(c)))
  512. {
  513. CreateAniline(79,delay_time);
  514. cout<<endl;
  515. c.putd();
  516. }
  517. CreateAniline(79,delay_time);
  518. bfile.close();
  519. getche();
  520. clrscr();
  521. main_menu();
  522. }
  523.  
  524. void recent()
  525. {
  526. ifstream fin("history.rap",ios::binary);
  527. if(!fin)
  528. {
  529. cout<<"\n\n\n\n\t\t\t\tNO RECENT HISTORY ";
  530. getche();
  531. clrscr();
  532. main_menu();
  533. }
  534. else
  535. {
  536. cout<<"CODE\t\t\tNAME\t\t\t\tBOUNTY";
  537. cout<<endl;
  538. CreateAniline(79,delay_time);
  539. while(fin.read((char*)&c,sizeof(c)))
  540. {
  541. c.putd();
  542. CreateAniline(79,delay_time);
  543. }
  544. fin.close();
  545. getche();
  546. clrscr();
  547. main_menu();
  548. }
  549. }
  550.  
  551. void clear_recent()
  552. {
  553. remove("history.rap");
  554. cout<<"\n\n\n\n\n\n\t\t\tHISTORY REMOVED ";
  555. getche();
  556. clrscr();
  557. main_menu();
  558. }
  559.  
  560.  
  561. void search()
  562. {
  563. int ch;
  564.  
  565. cout<<"\n\t\t\tPROFILE MENU";
  566. cout<<"\n\n\n\n\n\t\t\t1.SEARCH PROFILE BY CODE\n";
  567. cout<<"\t\t\t2.SEARCH PROFILE BY FIRST NAME\n";
  568. cout<<"\t\t\t3.SEARCH PROFILE BY BOUNTY\n";
  569. cout<<"\t\t\t4.BACK\n\n\n";
  570. cout<<"\t\t\tENTER YOUR CHOICE:";
  571. cin>>ch;
  572.  
  573. crimdata tmp;
  574. int p=-1;
  575. int r;
  576. long b;
  577. char tmp1[30];
  578.  
  579. if(ch==1)
  580. {
  581. ifstream cfile("MAIN.rap",ios::binary);
  582. clrscr();
  583. cout<<"ENTER THE CRIMINAL CODE:";
  584. cin>>r;
  585. clrscr();
  586. while(cfile.read((char*)&c, sizeof(c)))
  587. {
  588. if(c.getcode()==r)
  589. {
  590. p++;
  591. stmp=c;
  592. ofstream fout("history.rap",ios::binary|ios::app);
  593. fout.write((char*)&c, sizeof(c));
  594. fout.close();
  595. clrscr();
  596. mainmenu3();
  597. }
  598. }
  599. cfile.close();
  600. if(p==-1)
  601. {
  602. cout<<"\nRECORD NOT FOUND\n";
  603. getche();
  604. clrscr();
  605. main_menu();
  606. }
  607. }
  608.  
  609. else if(ch==2)
  610. {
  611. ifstream cfile("MAIN.rap",ios::binary);
  612. clrscr();
  613. cout<<"ENTER THE CRIMINAL FIRST NAME:";
  614. gets(tmp1);
  615. clrscr();
  616. while(cfile.read((char*)&c, sizeof(c)))
  617. {
  618. if(strcmp(c.getfirstname(),tmp1)==0)
  619. {
  620. p++;
  621. stmp=c;
  622. ofstream fout("history.rap",ios::binary|ios::app);
  623. fout.write((char*)&c, sizeof(c));
  624. fout.close();
  625. clrscr();
  626. mainmenu3();
  627. }
  628. }
  629. cfile.close();
  630. if(p==-1)
  631. {
  632. cout<<"\nRECORD NOT FOUND\n";
  633. getche();
  634. clrscr();
  635. main_menu();
  636. }
  637. }
  638.  
  639. else if(ch==3)
  640. {
  641. ifstream cfile("MAIN.rap",ios::binary);
  642. clrscr();
  643. cout<<"ENTER THE CRIMINAL BOUNTY:";
  644. cin>>b;
  645. clrscr();
  646. while(cfile.read((char*)&c, sizeof(c)))
  647. {
  648. if(c.getbounty()==b)
  649. {
  650. p++;
  651. stmp=c;
  652. ofstream fout("history.rap",ios::binary|ios::app);
  653. fout.write((char*)&c, sizeof(c));
  654. fout.close();
  655. clrscr();
  656. mainmenu3();
  657. }
  658. }
  659. cfile.close();
  660. if(p==-1)
  661. {
  662. cout<<"\nRECORD NOT FOUND\n";
  663. getche();
  664. clrscr();
  665. main_menu();
  666. }
  667. }
  668.  
  669. else if(ch==4)
  670. {
  671. clrscr();
  672. main_menu();
  673. }
  674.  
  675. else
  676. {
  677. cout<<"\nINVALID CHOICE. CHOOSE A VALID OPTION\n";
  678. getche();
  679. clrscr();
  680. search();
  681. }
  682. }
  683.  
  684.  
  685. void modify()
  686. {
  687. clrscr();
  688. int ch;
  689.  
  690. cout<<"\n\t\t\tMODIFY MENU";
  691. cout<<"\n\n\n\n\n\t\t\t1.MODIFY BY CODE\n";
  692. cout<<"\t\t\t2.MODIFY BY FIRST NAME\n";
  693. cout<<"\t\t\t3.MODIFY BY BOUNTY\n";
  694. cout<<"\t\t\t4.BACK\n\n\n";
  695. cout<<"\t\t\tENTER YOUR CHOICE:";
  696. cin>>ch;
  697. int p=-1,r,t=0;
  698. long b;
  699. char tmp[30];
  700. if(ch==1)
  701. {
  702. fstream finout("MAIN.rap",ios::binary|ios::in|ios::out);
  703. clrscr();
  704. cout<<"\nENTER THE CODE OF CRIMINAL:\n";
  705. cin>>r;
  706. clrscr();
  707. while(finout.read((char*)&c,sizeof(c)))
  708. {
  709. t++;
  710. if(c.getcode()==r)
  711. {
  712. p++;
  713. finout.seekp((t-1)*sizeof(c),ios::beg);
  714. c.getd();
  715. finout.write((char*)&c,sizeof(c));
  716. }
  717. }
  718. finout.close();
  719. if(p==-1)
  720. {
  721. cout<<"\nRECORD NOT FOUND!!!\n";
  722. getche();
  723. clrscr();
  724. main_menu();
  725. }
  726. else
  727. {
  728. cout<<"\nRECORD MODIFIED\n";
  729. getche();
  730. clrscr();
  731. main_menu();
  732. }
  733. }
  734.  
  735. else if(ch==2)
  736. {
  737. fstream finout("MAIN.rap",ios::binary|ios::in|ios::out);
  738. clrscr();
  739. cout<<"\nENTER THE FIRST NAME OF CRIMINAL:\n";
  740. gets(tmp);
  741. clrscr();
  742. while(finout.read((char*)&c,sizeof(c)))
  743. {
  744. t++;
  745. if(strcmp(c.getfirstname(),tmp)==0)
  746. {
  747. p++;
  748. finout.seekp((t-1)*sizeof(c),ios::beg);
  749. c.getd();
  750. finout.write((char*)&c,sizeof(c));
  751. }
  752. }
  753. finout.close();
  754. if(p==-1)
  755. {
  756. cout<<"\nRECORD NOT FOUND!!!\n";
  757. getche();
  758. clrscr();
  759. main_menu();
  760. }
  761. else
  762. {
  763. cout<<"\nRECORD MODIFIED\n";
  764. getche();
  765. clrscr();
  766. main_menu();
  767. }
  768. }
  769.  
  770. else if(ch==3)
  771. {
  772. fstream finout("MAIN.rap",ios::binary|ios::in|ios::out);
  773. clrscr();
  774. cout<<"\nENTER THE BOUNTY OF CRIMINAL:\n";
  775. cin>>b;
  776. clrscr();
  777. while(finout.read((char*)&c,sizeof(c)))
  778. {
  779. t++;
  780. if(c.getbounty()==b)
  781. {
  782. p++;
  783. finout.seekp((t-1)*sizeof(c),ios::beg);
  784. c.getd();
  785. finout.write((char*)&c,sizeof(c));
  786. }
  787. }
  788. finout.close();
  789. if(p==-1)
  790. {
  791. cout<<"\nRECORD NOT FOUND!!!\n";
  792. getche();
  793. clrscr();
  794. main_menu();
  795. }
  796. else
  797. {
  798. cout<<"\nRECORD MODIFIED\n";
  799. getche();
  800. clrscr();
  801. main_menu();
  802. }
  803. }
  804.  
  805. else if(ch==4)
  806. {
  807. clrscr();
  808. main_menu();
  809. }
  810. else
  811. {
  812. clrscr();
  813. cout<<"\n\n\n\n\t\t\t\tINVALID CHOICE...ENTER A VALID ONE\n";
  814. getche();
  815. clrscr();
  816. modify();
  817. }
  818. }
  819. void Delete()
  820. {
  821. int r;
  822. cout<<"\nENTER CRIMINAL CODE TO BE REMOVED:\n";
  823. cin>>r;
  824. ofstream fout("tmp.rap",ios::binary|ios::out);
  825. ifstream fin("MAIN.rap",ios::binary|ios::in);
  826. while(fin.read((char*)&c,sizeof(c)))
  827. {
  828. if(c.getcode()!=r)
  829. {
  830. fout.write((char*)&c,sizeof(c));
  831. }
  832. }
  833. remove("MAIN.rap");
  834. rename("tmp.rap","MAIN.rap");
  835.  
  836. fin.close();
  837. fout.close();
  838. cout<<"\nRECORD REMOVED\n";
  839. getche();
  840. clrscr();
  841. main_menu();
  842. }
  843.  
  844. void delay(long i)
  845. {
  846. for(long j=0;j<=i;j++)
  847. {}
  848. }
  849.  
  850. void CreateAniline(int s,long t)
  851. {
  852. for(int k=0;k<=s;k++)
  853. {
  854. cout<<"-";
  855. delay(t);
  856. }
  857. }
  858.  
  859. void mainmenu3()
  860. {
  861. clrscr();
  862. int c;
  863. cout<<"\n";
  864. CreateAniline(79,delay_time);
  865. cout<<"\nNAME:"<<stmp.getfirstname()<<" "<<stmp.getlastname()<<"\t\t\t\t"<<"BOUNTY:"<<stmp.getbounty()<<endl;
  866. cout<<"COST TO STATE:"<<stmp.getcst()<<"\t\t\t\t"<<"FINES DUE:"<<stmp.getfines()<<endl;
  867. CreateAniline(79,delay_time);
  868. cout<<"\n\n\n";
  869. char str1[20];
  870. cout<<"1. ADD VEHICLE USED\n";
  871. cout<<"2. ADD INFRACTION CAUSED\n";
  872. cout<<"3. DELETE VEHICLE USED\n";
  873. cout<<"4. DELETE INFRACTION CAUSED\n";
  874. cout<<"5. DISPLAY VEHICLE USED\n";
  875. cout<<"6. DISPLAY INFRACTIONS CAUSED\n";
  876. cout<<"7. DISPLAY CASE HISTORY\n";
  877. cout<<"8. BACK\n";
  878. cout<<"\n\n";
  879. cout<<"ENTER YOUR CHOICE:";
  880. cin>>c;
  881.  
  882. switch(c)
  883. {
  884. case 1:
  885. add_car();
  886. break;
  887.  
  888. case 2:
  889. add_inf();
  890. break;
  891.  
  892. case 3:
  893. delete_car();
  894. break;
  895.  
  896. case 4:
  897. delete_inf();
  898. break;
  899.  
  900. case 5:
  901. display_car();
  902. break;
  903.  
  904. case 6:
  905. display_inf();
  906. break;
  907.  
  908. case 7:
  909. clrscr();
  910. cout<<"\t\t\t\tCASE HISTORY"<<endl;
  911. CreateAniline(79,delay_time);
  912. puts(stmp.getcasehistory());
  913. cout<<endl;
  914. CreateAniline(79,delay_time);
  915. getche();
  916. clrscr();
  917. mainmenu3();
  918. break;
  919.  
  920. case 8:
  921. clrscr();
  922. main_menu();
  923. break;
  924.  
  925. default:
  926. cout<<"\nINVALID CHOICE\n";
  927. getche();
  928. clrscr();
  929. mainmenu3();
  930. }
  931. }
  932.  
  933. void add_car()
  934. {
  935. clrscr();
  936. char car[40];
  937. char fileext[45];
  938. strcpy(car,"car");
  939. strcpy(fileext,".car");
  940. strcat(car,stmp.getfirstname());
  941. strcat(car,fileext);
  942. ofstream fout(car,ios::binary|ios::app);
  943. v.getd();
  944. fout.write((char*)&v,sizeof(v));
  945. fout.close();
  946. cout<<"\n\n"<<"CAR ADDED";
  947. getche();
  948. clrscr();
  949. mainmenu3();
  950. }
  951.  
  952. void add_inf()
  953. {
  954. clrscr();
  955. char inf[40];
  956. char fileext[45];
  957. strcpy(inf,"inf");
  958. strcpy(fileext,".inf");
  959. strcat(inf,stmp.getfirstname());
  960. strcat(inf,fileext);
  961. ofstream fout(inf,ios::binary|ios::app);
  962. i.getd();
  963. fout.write((char*)&i,sizeof(i));
  964. fout.close();
  965. cout<<"\n\n"<<"INFRACTION ADDED";
  966. getche();
  967. clrscr();
  968. mainmenu3();
  969. }
  970.  
  971. void delete_car()
  972. {
  973. clrscr();
  974. char carname[50];
  975. char car[40];
  976. char fileext[45];
  977. strcpy(car,"car");
  978. strcpy(fileext,".car");
  979. strcat(car,stmp.getfirstname());
  980. strcat(car,fileext);
  981. cout<<"ENTER THE NAME OF CAR";
  982. gets(carname);
  983. ofstream fout("tmp.car",ios::binary);
  984. ifstream fin(car,ios::binary);
  985. while(fin.read((char*)&v,sizeof(v)))
  986. {
  987. if(strcmp(v.getvname(),carname)!=0)
  988. {
  989. fout.write((char*)&v,sizeof(v));
  990. }
  991. }
  992.  
  993. remove(car);
  994. rename("tmp.dat",car);
  995. fout.close();
  996. fin.close();
  997.  
  998. cout<<"\n\nCAR DELETED";
  999. getche();
  1000. clrscr();
  1001. mainmenu3();
  1002. }
  1003.  
  1004. void delete_inf()
  1005. {
  1006. clrscr();
  1007. char infname[50];
  1008. char inf[40];
  1009. char fileext[45];
  1010. strcpy(inf,"inf");
  1011. strcpy(fileext,".inf");
  1012. strcat(inf,stmp.getfirstname());
  1013. strcat(inf,fileext);
  1014. cout<<"ENTER THE NAME OF INFRACTION";
  1015. gets(infname);
  1016. ofstream fout("tmp.inf",ios::binary);
  1017. ifstream fin(inf,ios::binary);
  1018. while(fin.read((char*)&i,sizeof(i)))
  1019. {
  1020. if(strcmp(i.getiname(),infname)!=0)
  1021. {
  1022. fout.write((char*)&i,sizeof(i));
  1023. }
  1024. }
  1025.  
  1026. remove(inf);
  1027. rename("tmp.dat",inf);
  1028. fin.close();
  1029. fout.close();
  1030.  
  1031. cout<<"\n\nINFRACTION DELETED";
  1032.  
  1033. getche();
  1034. clrscr();
  1035. mainmenu3();
  1036. }
  1037.  
  1038. void display_inf()
  1039. {
  1040. clrscr();
  1041. char inf[40];
  1042. char fileext[45];
  1043. strcpy(inf,"inf");
  1044. strcpy(fileext,".inf");
  1045. strcat(inf,stmp.getfirstname());
  1046. strcat(inf,fileext);
  1047.  
  1048. ifstream fin(inf,ios::binary);
  1049. cout<<"INFRACTION\t\t\t\tNO OF TIMES"<<endl;
  1050. while(fin.read((char*)&i,sizeof(i)))
  1051. {
  1052. CreateAniline(79,delay_time);
  1053. cout<<endl;
  1054. i.putd();
  1055. cout<<endl;
  1056. }
  1057.  
  1058. CreateAniline(79,delay_time);
  1059. getche();
  1060. clrscr();
  1061. mainmenu3();
  1062. }
  1063.  
  1064. void display_car()
  1065. {
  1066. clrscr();
  1067. char car[40];
  1068. char fileext[45];
  1069. strcpy(car,"car");
  1070. strcpy(fileext,".car");
  1071. strcat(car,stmp.getfirstname());
  1072. strcat(car,fileext);
  1073.  
  1074. ifstream fin(car,ios::binary);
  1075. cout<<"VEHICLE NAME\t\t\t\tIMPOUND STRIKES"<<endl;
  1076. while(fin.read((char*)&v,sizeof(v)))
  1077. {
  1078. CreateAniline(79,delay_time);
  1079. cout<<endl;
  1080. v.putd();
  1081. cout<<endl;
  1082. }
  1083.  
  1084. CreateAniline(79,delay_time);
  1085. getche();
  1086. clrscr();
  1087. mainmenu3();
  1088. }
  1089.  
  1090.  
  1091. void main()
  1092. {
  1093. clrscr();
  1094. char ch,tmp[30];
  1095. int t=0;
  1096. ifstream fin("pass.dat",ios::binary);
  1097. if(fin)
  1098. {
  1099. clrscr();
  1100. fin.close();
  1101. login_menu();
  1102. }
  1103. else
  1104. {
  1105. cout<<"\nSET A DEFAULT PASSCODE...YOU CAN CHANGE IT LATER\n";
  1106. cout<<"\nENTER PASSCODE:";
  1107. while(ch!=13)
  1108. {
  1109. ch=getch();
  1110. if(ch==8)
  1111. {
  1112. clrscr();
  1113. cout<<"\nSET A DEFAULT PASSCODE...YOU CAN CHANGE IT LATER\n";
  1114. cout<<"\nENTER PASSCODE:";
  1115. t=t-1;
  1116. for(int i=0;i<t;i++)
  1117. {
  1118. cout<<"*";
  1119. }
  1120. tmp[t]='\0';
  1121. }
  1122. else
  1123. {
  1124. tmp[t]=ch;
  1125. cout<<"*";
  1126. t++;
  1127. }
  1128. }
  1129. tmp[t-1]='\0';
  1130.  
  1131. strcpy(pass,tmp);
  1132. int l=strlen(pass);
  1133. ofstream fout("pass.dat",ios::binary|ios::trunc);
  1134. for(int i=0;i<=l;i++)
  1135. {
  1136. fout.put(pass[i]);
  1137. }
  1138. fout.close();
  1139. cout<<"\nPASSWORD SET SUCCESSFULLY\n";
  1140. getche();
  1141. clrscr();
  1142. login_menu();
  1143. }
  1144. }
Advertisement
Add Comment
Please, Sign In to add comment