Advertisement
Guest User

Untitled

a guest
May 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. class Pytanie { //klasa bazowa
  8. protected:
  9. string pytanie;
  10. string odpowiedz;
  11. public:
  12. virtual void UstawOdpowiedz(string odp )=0;
  13.  
  14. void UstawPytanie(string pytanie){
  15. this-> pytanie = pytanie;
  16. } // ustawia pytanie w zmiennej pytsanie
  17. //[przypisanie zmiennej pytania odpowiedniej wartoœci
  18. string PobierzPytanie(){
  19. return pytanie;
  20. }
  21. };
  22.  
  23. class Ocen : Pytanie {
  24. private:
  25. int x, y ;
  26. public:
  27. Ocen (int x, int y, string pyt) { //x poczaatek przedZIalu, y koniec przedzialu
  28. this->y = y;
  29. this->x = x;
  30. // ustawienie zmiennych powyzej z przedzialu x do y
  31. UstawPytanie(pyt); //wywoloanie metody klasy bazowe Pytanie
  32.  
  33. }
  34. void UstawOdpowiedz (string odp ){
  35. if (Sprawdz(odp))
  36. {
  37. this-> odpowiedz = odp;
  38. }
  39. else
  40. {
  41. //todo zastanowic sie jak zrobic
  42. //dac kolejna mozliwosc odpowiedziedzi
  43. }
  44. }
  45. private:
  46. bool Sprawdz (string odp ){
  47. // atoi(odp); //atoi zamienia stringa na inta
  48. int liczba = stoi(odp); // albo stoi
  49. if (liczba >=x && liczba <=y )
  50. {
  51. return true;
  52. }
  53. else
  54. {
  55. return false;
  56. }
  57. }
  58.  
  59. };
  60.  
  61.  
  62. class PytanieOtwarte : Pytanie{ //niby skonczone
  63. public:
  64. void UstawOdpowiedz(string odp ){
  65. this->odpowiedz=odp;
  66. }
  67.  
  68.  
  69. };
  70.  
  71. class PytanieZamkniete : Pytanie {
  72. private:
  73. string a,b,c,d;
  74. public:
  75. void UstawOdpowiedz(string a) ////
  76.  
  77.  
  78. };
  79.  
  80. class Wczytacz {
  81. public:
  82. PytanieOtwarte *WczytajOtwarte(string linia){ //-----------------
  83. PytanieOtwarte *NowePytanie = new PytanieOtwarte();
  84. int index =0; //otwarte
  85. index = find("###");
  86. NowePytanie->UstawPytanie(substr(0,index)); //ustawianie pytanie
  87.  
  88. return NowePytanie; //-------------------------------------------------------------
  89. }
  90. Ocen *WczytajSkale(string linia){ //-----------------------------------
  91. //Ocen *NowaSkala = new Ocen();
  92. int index =0;
  93. index = find("###");
  94.  
  95. string temp = substr(index+4, temp.length()) // chwyta wszystko za haszami
  96.  
  97. /////
  98.  
  99.  
  100.  
  101. }
  102.  
  103. };
  104.  
  105. class WczytaniePliku{
  106. public:
  107.  
  108. void load(int question_number) {
  109.  
  110. ifstream file("quiz.txt");
  111. string line;
  112.  
  113. if(file.fail()) exit(1);
  114.  
  115. for(int i=0; i<-4+6*question_number; ++i)
  116. getline(file, line);
  117.  
  118. for(int i=0; i<6; i++) {
  119.  
  120. getline(file, line);
  121. switch(i) {
  122.  
  123. case 0: content = line; break;
  124. case 1:
  125. case 2:
  126. case 3:
  127. case 4: answers[i-1] = line; break;
  128. case 5: correct_answer = line.back(); break;
  129. }
  130. }
  131. }
  132.  
  133.  
  134.  
  135. };
  136.  
  137.  
  138.  
  139. int main()
  140. {
  141. cout << "Hello world!" << endl;
  142. return 0;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement