All pastes #71157 Raw Edit

Anonymous

public text v1 · immutable
#71157 ·published 2006-06-25 10:59 UTC
rendered paste body
#include <iostream>
#include <string>
using namespace std;

class CQuiz {
private:
        int c_nQuestions;
        int c_nCorrectAnswers;
public:
        CQuiz() {
                c_nQuestions = c_nCorrectAnswers = 0;
        }
        
        void AskQuestion(string sQuestion, string sCorrectAnswer) {
                string sAnswer;
                bool bAnswer;
                
                /* Increase question count */
                cout << ++c_nQuestions << ". " << sQuestion << endl;
                cin >> sAnswer;
                
                transform(sCorrectAnswer.begin(), sCorrectAnswer.end(), sCorrectAnswer.begin(), (int(*)(int)) std::tolower);
                transform(sAnswer.begin(), sAnswer.end(), sAnswer.begin(), (int(*)(int)) std::tolower);
                
                if (StrCaseCmp(sAnswer, sCorrectAnswer)) {
                        cout << "Riktig" << endl << endl;
                        c_nCorrectAnswers++;
                } else {
                        cout << "Feil, riktig svar var: " << sCorrectAnswer << endl << endl;
                }
        }
        
        void ShowResult() {
                cout << "Du har " << c_nCorrectAnswers << " av " << c_nQuestions << " riktige!" << endl;
        }
};

int main(int argc, char* argv[]) {
        CQuiz Quiz;
        Quiz.AskQuestion("Hvilken klan var Tecfan i før?", "Abandoned");
        Quiz.AskQuestion("Er CNU skilled med C++?", "Ja");
        Quiz.AskQuestion("Hvem blir iflg. Amnesia verdenshersker innen 5 år?", "CNU");
        Quiz.ShowResult();
        system("pause");
}