⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 whatstheface.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include <fstream>
using namespace std;

#include "whatstheface.h"
#include "randgen.h"
#include "strutils.h"  // for LowerString

WhatsTheQuestion::WhatsTheQuestion()
  : myPrompt("no questions")
{ }

WhatsTheQuestion::WhatsTheQuestion(const string& prompt,
                 const string& filename)
{
    Open(prompt,filename);
}                 

void WhatsTheQuestion::Open(const string& prompt,
                            const string& filename)
{
    myPrompt = prompt;
    ifstream input(filename.c_str());
    string first,second;
    while (getline(input,first) && getline(input,second))
    {    myQuestions.push_back(Quest(first,second));
    }
}                            

void WhatsTheQuestion::Create()
{
    RandGen gen;
    myQIndex = gen.RandInt(0,myQuestions.size()-1);
}

void WhatsTheQuestion::Ask() const
{
    cout << myPrompt << " " << myQuestions[myQIndex].first << " : ";
}

bool WhatsTheQuestion::IsCorrect(const string& answer) const
{
    return LowerString(answer) == 
           LowerString(myQuestions[myQIndex].second);
}

string WhatsTheQuestion::Answer() const
{
    return myQuestions[myQIndex].second;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -