Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Pytanie { //klasa bazowa
- protected:
- string pytanie;
- string odpowiedz;
- public:
- virtual void UstawOdpowiedz(string odp )=0;
- void UstawPytanie(string pytanie){
- this-> pytanie = pytanie;
- } // ustawia pytanie w zmiennej pytsanie
- //[przypisanie zmiennej pytania odpowiedniej wartoœci
- string PobierzPytanie(){
- return pytanie;
- }
- };
- class Ocen : Pytanie {
- private:
- int x, y ;
- public:
- Ocen (int x, int y, string pyt) { //x poczaatek przedZIalu, y koniec przedzialu
- this->y = y;
- this->x = x;
- // ustawienie zmiennych powyzej z przedzialu x do y
- UstawPytanie(pyt); //wywoloanie metody klasy bazowe Pytanie
- }
- void UstawOdpowiedz (string odp ){
- if (Sprawdz(odp))
- {
- this-> odpowiedz = odp;
- }
- else
- {
- //todo zastanowic sie jak zrobic
- //dac kolejna mozliwosc odpowiedziedzi
- }
- }
- private:
- bool Sprawdz (string odp ){
- // atoi(odp); //atoi zamienia stringa na inta
- int liczba = stoi(odp); // albo stoi
- if (liczba >=x && liczba <=y )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- };
- class PytanieOtwarte : Pytanie{ //niby skonczone
- public:
- void UstawOdpowiedz(string odp ){
- this->odpowiedz=odp;
- }
- };
- class PytanieZamkniete : Pytanie {
- private:
- string a,b,c,d;
- public:
- void UstawOdpowiedz(string a) ////
- };
- class Wczytacz {
- public:
- PytanieOtwarte *WczytajOtwarte(string linia){ //-----------------
- PytanieOtwarte *NowePytanie = new PytanieOtwarte();
- int index =0; //otwarte
- index = find("###");
- NowePytanie->UstawPytanie(substr(0,index)); //ustawianie pytanie
- return NowePytanie; //-------------------------------------------------------------
- }
- Ocen *WczytajSkale(string linia){ //-----------------------------------
- //Ocen *NowaSkala = new Ocen();
- int index =0;
- index = find("###");
- string temp = substr(index+4, temp.length()) // chwyta wszystko za haszami
- /////
- }
- };
- class WczytaniePliku{
- public:
- void load(int question_number) {
- ifstream file("quiz.txt");
- string line;
- if(file.fail()) exit(1);
- for(int i=0; i<-4+6*question_number; ++i)
- getline(file, line);
- for(int i=0; i<6; i++) {
- getline(file, line);
- switch(i) {
- case 0: content = line; break;
- case 1:
- case 2:
- case 3:
- case 4: answers[i-1] = line; break;
- case 5: correct_answer = line.back(); break;
- }
- }
- }
- };
- int main()
- {
- cout << "Hello world!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement