Advertisement
Wh0CaREs

UnderDevelop

Feb 2nd, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.11 KB | None | 0 0
  1. /* ToDO
  2. 1. Student prijave
  3. 2. Student report
  4. 3. Profesor ocjena
  5. BUGs:
  6. 1. Exit Admin 2 puta moram 4 uprijeti
  7. */
  8. #include <iostream>
  9. #include <string>
  10. using namespace std;
  11. typedef int B;
  12. typedef char C;
  13. const B v=25;
  14. const B p=15;
  15. struct users{
  16.     string ime,prezime,username,password,activ;
  17.     B dan,mjesec,godina,oim,uit,oep,upr,id;
  18. };
  19. users studenti[v], profesori[p],adm;
  20. B tbstudenti=0,tbprofesora=0,sesionid,seslvl;
  21. bool cantfinduser=false;
  22. bool prvil=true,/* provjeraje da li je prvi put da se program pokrenuo... */ userdel=false,frommeni=true;
  23. bool studentm=false,profm=false;
  24. bool oep=false,uit=false,upr=false,oim=false;
  25. void pispiti();
  26. void givemark();
  27. void profil();
  28. void kojimeni();
  29. void nastavnik();
  30. void admin();
  31. void adminmeni();
  32. void studentmeni();
  33. void profesormeni();
  34. void adduser(users[],B&);
  35. void deleteuser(users[],B&);
  36.  
  37. void header();
  38. B login();
  39. B main (){
  40.  
  41.     adm.username = "admin", adm.password = "password"; // default adm & pw
  42.     do{
  43.         header();
  44.         seslvl=login();
  45.         if(seslvl==3)
  46.             admin();
  47.         else if(seslvl==2)
  48.             nastavnik();
  49.     }while(1);
  50.  
  51.     system("pause>0");
  52.     return 0;
  53. }
  54. void header(){
  55.     system("cls");
  56.     cout<<"|**********************************|"<<endl;
  57.     cout<<"|************** DL CMS ************|"<<endl;
  58.     cout<<"|**********************************|\n\n\n"<<endl;
  59.  
  60. }
  61. B login(){
  62.     string user,pw;
  63.     B lvl=0;
  64.     oep=uit=oim=upr=false;
  65.     cout<<"Dobro dosli\nLogirajte se"<<endl;
  66.     cout<<"Username : ";
  67.     getline(cin,user);
  68.     cout<<"Password: ";
  69.     getline(cin,pw);
  70.  
  71.     for(B i=0;i<v;i++){
  72.         if(user==adm.username && pw==adm.password){
  73.             lvl=3;
  74.             sesionid=0;
  75.             i=v;
  76.         }
  77.         else if (user==studenti[i].username && pw==studenti[i].password){
  78.             lvl=1;
  79.             sesionid=i;
  80.             i=v;
  81.         }
  82.         else if(i<15){
  83.             if (user==profesori[i].username && pw==profesori[i].password){
  84.                 lvl=2;
  85.                 sesionid=i;
  86.                 if(profesori[i].oep==5)
  87.                     oep=true;
  88.                 if(profesori[i].oim==5)
  89.                     oim=true;
  90.                 if(profesori[i].uit==5)
  91.                     uit=true;
  92.                 if(profesori[i].upr==5)
  93.                     upr=true;
  94.                 i=v;
  95.             }
  96.         }
  97.  
  98.     }
  99.  
  100.     return lvl;
  101.  
  102. }
  103. void admin(){
  104.     string pin,pin2;
  105.     system("cls");
  106.  
  107.     if(prvil==true){
  108.         do{
  109.  
  110.             header();
  111.             cout<<"Unesite novi pin"<<endl;
  112.             cin>>pin;
  113.             header();
  114.             cout<<"Unesite opet novi pin"<<endl;
  115.             cin>>pin2;
  116.             system("cls");
  117.         }while(pin!=pin2);
  118.         adm.password=pin;
  119.         prvil=false;
  120.     }
  121.  
  122.     header();
  123.     adminmeni();
  124.  
  125.  
  126. }
  127. void adminmeni(){
  128.     B izbor=0;
  129.     bool exit=false;
  130.     do{
  131.         if(frommeni==true)
  132.             header();
  133.         cout<<"1.Student\n2.Nastavnik\n3.Profil\n4.Exit"<<endl;
  134.         do{
  135.             cin>>izbor;
  136.         }while(izbor<0 && izbor>4);
  137.         if(izbor==1){
  138.             if(frommeni=true)
  139.                 header();
  140.             studentmeni();
  141.             frommeni=false;
  142.         }
  143.         else if(izbor==2)
  144.             profesormeni();
  145.         else if(izbor==3)
  146.             profil();
  147.         else if(izbor==4)
  148.             exit=true;
  149.     }while(exit!=true);
  150.  
  151.    
  152.  
  153.  
  154. }
  155. void studentmeni(){
  156.     B izbor;
  157.     do{
  158.         studentm=true;
  159.         if(frommeni==true){
  160.             header();
  161.             frommeni=false;
  162.         }
  163.         if(cantfinduser==true){
  164.             cout<<"Korisnik nije pronadjen\n\n"<<endl;
  165.             cantfinduser=false;
  166.         }
  167.         else if (userdel==true){
  168.             cout<<"Korisnik je izbrisan\n\n"<<endl;
  169.             userdel=false;
  170.         }
  171.         cout<<"1. Dodaj studenta\n2. Izbrisi studenta\n3. Exit"<<endl;
  172.         do{cin>>izbor;}while(izbor<1 && izbor>2);
  173.         if(izbor==1)
  174.             adduser(studenti,tbstudenti);
  175.         else if(izbor==2)
  176.             deleteuser(studenti,tbstudenti);
  177.     }while(izbor!=3);
  178.     frommeni=true;
  179.     studentm=false;
  180.     adminmeni();
  181. }
  182. void profesormeni(){
  183.     B izbor;
  184.     do{
  185.         profm=true;
  186.         if(frommeni==true){
  187.             header();
  188.             frommeni=false;
  189.         }
  190.         if(cantfinduser==true){
  191.             cout<<"Korisnik nije pronadjen\n\n"<<endl;
  192.             cantfinduser=false;
  193.         }
  194.         else if (userdel==true){
  195.             cout<<"Korisnik je izbrisan\n\n"<<endl;
  196.             userdel=false;
  197.         }
  198.         cout<<"1. Dodaj profesora\n2. Izbrisi profesora\n3. Exit"<<endl;
  199.         do{cin>>izbor;}while(izbor<1 && izbor>2);
  200.         if(izbor==1)
  201.             adduser(profesori,tbprofesora);
  202.         else if(izbor==2)
  203.             deleteuser(profesori,tbprofesora);
  204.     }while(izbor!=3);
  205.     frommeni=true;
  206.     profm=false;
  207.     adminmeni();
  208. }
  209. void adduser(users korisnik[],B &tren){
  210.     B izbor,izbor2;
  211.     bool slobodanusername=true;
  212.     string tempuser;
  213.     system("cls");
  214.     header();
  215.     cout<<"\t\t DODAVANJE\n\n"<<endl;
  216.     cout<<"Ime:";
  217.     cin>>korisnik[tren].ime;
  218.     cout<<"Prezime:";
  219.     cin>>korisnik[tren].prezime;
  220.     do{
  221.         slobodanusername=true;
  222.         cout<<"Username:";
  223.         cin>>tempuser;
  224.         for(B i=0;i<tbstudenti;i++)
  225.             if(studenti[i].username==tempuser){
  226.                 slobodanusername=false;
  227.                 i=tbstudenti;
  228.             }
  229.             if(slobodanusername==true){
  230.                 for(B i=0;i<tbprofesora;i++)
  231.                     if(profesori[i].username==tempuser){
  232.                         slobodanusername=false;
  233.                         i=tbprofesora;
  234.                     }
  235.             }
  236.     }while(slobodanusername==false);
  237.     korisnik[tren].username=tempuser;
  238.     cout<<"Dan Mjesec Godina:";
  239.     cin>>korisnik[tren].dan >> korisnik[tren].mjesec >> korisnik[tren].godina;
  240.     korisnik[tren].password="0000";
  241.     if(studentm==true){
  242.         korisnik[tren].uit=korisnik[tren].oep=korisnik[tren].upr=0;
  243.         korisnik[tren].oim=1;
  244.     }
  245.     else if(profm==true){
  246.         do{
  247.             cout<<"Predmet:\n1.OIM\n2.UPR\n3.OEP\n4.UIT"<<endl;
  248.             do{
  249.                 cin>>izbor;
  250.             }while(izbor<1 && izbor>4);
  251.             switch(izbor){
  252.             case 1: korisnik[tren].oim = 5;break;
  253.             case 2: korisnik[tren].upr = 5;break;
  254.             case 3: korisnik[tren].oep = 5;break;
  255.             case 4: korisnik[tren].uit = 5;break;
  256.             }
  257.             cout<<"Da li profesor predaje jos neki predmet??\n1.Da\n2.Ne"<<endl;
  258.             cin>>izbor2;
  259.             if(izbor2==1)
  260.                 header();
  261.         }while(izbor2==1);
  262.     }
  263.     header();
  264.     frommeni=false;
  265.     cout<<"Uspjesno ste unjeli:"<<endl;
  266.     cout<<korisnik[tren].ime<<" "<<korisnik[tren].prezime<<" "<<korisnik[tren].dan<<" "<<korisnik[tren].mjesec<<" "<<korisnik[tren].godina;
  267.     if(profm==true){
  268.         if(korisnik[tren].oep == 5)
  269.             cout<<" OEP";
  270.         if(korisnik[tren].oim == 5)
  271.             cout<<" OIM";
  272.         if(korisnik[tren].uit == 5)
  273.             cout<<" UIT";
  274.         if(korisnik[tren].upr == 5)
  275.             cout<<" UPR";
  276.     }
  277.     cout<<"\n\n";
  278.     tren++;
  279. }
  280. void deleteuser(users korisnik[],B &tren){
  281.     string ime,prezime;
  282.     B temp=-1,brisanje;
  283.     B dan,mjesec,godina;
  284.     header();
  285.     cout<<"\t\t BRISANJE KORISNIKA\n\n"<<endl;
  286.    
  287.     cout<<"Ukucajte ime: ";
  288.     getline(cin,ime);
  289.     cout<<"Ukucajte prezime: ";
  290.     getline(cin,prezime);
  291.     cout<<"Dan Mjesec Godina: ";
  292.     cin>>dan>>mjesec>>godina;
  293.  
  294.     for(B i=0; i<tren;i++)
  295.         if(ime==korisnik[i].ime && prezime==korisnik[i].prezime && dan==korisnik[i].dan && mjesec==korisnik[i].mjesec && godina==korisnik[i].godina)
  296.             temp=i;
  297.     if(temp!=-1){
  298.         header();
  299.         cout<<"\nPronadjen je korisnik"<<endl;
  300.         cout<<korisnik[temp].ime<<" "<<korisnik[temp].prezime<<" "<<korisnik[temp].dan<<" "<<korisnik[temp].mjesec<<" "<<korisnik[temp].godina<<endl;
  301.         cout<<"\n\nZelite li ga obrisati??"<<endl;
  302.         cout<<"1. Da\n2. Ne"<<endl;
  303.         cin>>brisanje;
  304.         if(brisanje==1){
  305.             for(B i=temp; i<tren;i++){
  306.                 korisnik[i] = korisnik[i+1];
  307.             }
  308.             userdel=true;
  309.         }
  310.     }
  311.     else{
  312.         cantfinduser=true;
  313.         kojimeni();
  314.     }
  315.     kojimeni();
  316.  
  317. }
  318. void kojimeni(){
  319.     frommeni=true;
  320.     if(studentm=true){
  321.         studentmeni();
  322.  
  323.     }
  324.     else if (profm=true){
  325.         profesormeni();
  326.     }
  327.     else if(seslvl==1){
  328.         // u student meni
  329.     }
  330.     else if(seslvl==2){
  331.         // profesorov meni
  332.     }
  333.  
  334. }
  335.  
  336. void profil(){
  337.     string pw;
  338.     B izbor;
  339.     header();
  340.     cout<<"1. Promjeni password"<<endl;
  341.     cin>>izbor;
  342.     if (izbor==1){
  343.         header();
  344.         if(seslvl==1){
  345.             cout<<"Unesite novi password"<<endl;
  346.             getline(cin,pw);
  347.             studenti[sesionid].password=pw;
  348.         }
  349.  
  350.         else if (seslvl==3){
  351.             cout<<"Unesite novi password"<<endl;
  352.             getline(cin,pw);
  353.             adm.password = pw;
  354.             adminmeni();
  355.         }
  356.         else {
  357.             cout<<"Unesite novi password"<<endl;
  358.             getline(cin,pw);
  359.             profesori[sesionid].password=pw;
  360.         }
  361.     }
  362. }
  363.  
  364. void pispiti(){
  365.     B izbor,izlaz;
  366.     header();
  367.     if(oep==true)
  368.         cout<<"1.Ekonomija"<<endl;
  369.     if(oim==true)
  370.         cout<<"2.Oim"<<endl;
  371.     if(upr==true)
  372.         cout<<"3.UPR"<<endl;
  373.     if(uit==true)
  374.         cout<<"4.UIT"<<endl;
  375.     cin>>izbor;
  376.     if(izbor==1 && oep==true){
  377.         cout<<"Lista prijavljenih studenata je"<<endl;
  378.         for(B i=0;i<tbstudenti;i++){
  379.             if(studenti[i].oep==1)
  380.                 cout<<i<<". "<<studenti[i].ime<<" "<<studenti[i].prezime<<endl;
  381.         }
  382.     }
  383.     else if(izbor==2 && oim==true){
  384.         cout<<"Lista prijavljenih studenata je"<<endl;
  385.         for(B i=0;i<tbstudenti;i++){
  386.             if(studenti[i].oim==1)
  387.                 cout<<i<<". "<<studenti[i].ime<<" "<<studenti[i].prezime<<endl;
  388.         }
  389.     }
  390.     else if(izbor==3 && upr==true){
  391.         cout<<"Lista prijavljenih studenata je"<<endl;
  392.         for(B i=0;i<tbstudenti;i++){
  393.             if(studenti[i].upr==1)
  394.                 cout<<i<<". "<<studenti[i].ime<<" "<<studenti[i].prezime<<endl;
  395.         }
  396.     }
  397.     else if(izbor==4 && uit==true){
  398.         cout<<"Lista prijavljenih studenata je"<<endl;
  399.         for(B i=0;i<tbstudenti;i++){
  400.             if(studenti[i].uit==1)
  401.                 cout<<i<<". "<<studenti[i].ime<<" "<<studenti[i].prezime<<endl;
  402.         }
  403.     }
  404.     cout<<"\n\n\t Meni\n";
  405.     cout<<"1. Nazad"<<endl;
  406.     cout<<"2.Daj ocjenu"<<endl;
  407.     do{cin>>izlaz;}while(izlaz<1  && izlaz>3);
  408.     if(izlaz==2)
  409.         givemark();
  410. }
  411. void nastavnik(){
  412.     B izbor=0;
  413.     bool exit=false;
  414.     header();
  415.     cout<<"1.Izlistaj prijavljene ispite\n2.Daj ocjenu\n3.Obrisi ocjenu\n4.Profil\n5.Exit"<<endl;
  416.     do{cin>>izbor;}while(izbor<1 && izbor>5);
  417.     switch(izbor){
  418.     case 1 :pispiti();
  419.     /* case 3 : deletemark();break;  */
  420.     case 4 : profil();break;
  421.     }
  422.  
  423. }
  424. void givemark(){
  425.     header();
  426.     B izbor=1,student,ocjena;
  427.     if(oim==true && izbor==1)
  428.         for(B i=0;i<tbstudenti;i++)
  429.             if(studenti[i].oim==1)
  430.                 cout<<i<<"."<<studenti[i].ime<<" "<<studenti[i].prezime<<" "<<studenti[i].dan<<" "<<studenti[i].mjesec<<" "<<studenti[i].godina<<endl;
  431.     cout<<"Unesite redni broj studenta: "<<endl;
  432.     do{cin>>student;}while(studenti[student].oim!=1);
  433.     cout<<"Unesite ocjenu"<<endl;
  434.     do{cin>>ocjena;}while(ocjena<5 && ocjena>10);
  435.     studenti[student].oim=ocjena;
  436. }
  437. void deletemark(){
  438.     header();
  439.     B izbor=1,student,ocjena;
  440.     if(oim==true && izbor==1)
  441.         for(B i=0;i<tbstudenti;i++)
  442.             if(studenti[i].oim>5)
  443.                                 cout<<i<<"."<<studenti[i].ime<<" "<<studenti[i].prezime<<" "<<studenti[i].dan<<" "<<studenti[i].mjesec<<" "<<studenti[i].godina<<endl;
  444.     cout<<"Unesite redni broj studenta: "<<endl;
  445.     do{cin>>student;}while(studenti[student].oim!=1);
  446.     cout<<"Unesite ocjenu"<<endl;
  447.     do{cin>>ocjena;}while(ocjena<5 && ocjena>10);
  448.     studenti[student].oim=ocjena;
  449.  
  450. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement