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

📄 whatstheface.h

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 H
字号:
#ifndef _WHATSTHEQUESTION_H
#define _WHATSTHEQUESTION_H

#include <string>
using namespace std;

// see "questface.h" for details on member functions
//
// A class for generating quiz questions like
// "What's the capital of Arkansas"
// "Who wrote Neuromancer"
// "What artist recorded 'Are You Gonna Go My Way'"
//
// A file of questions is read, one is used at random each time Create
// is called.  The file is in the format
//
// question
// answer
// question
// answer
//
// i.e., a question uses two lines, the answer is the second line, the
// question is the first line:
//
// Terrapin Station
// Grateful Dead
// Hoist
// Phish
// It's A Shame About Ray
// Lemonheads
// -------------------
//
// The constructor and method Open take a prompt and a file of questions
// as parameters, e.g.,
// WhatsTheQuestion capitals("What's the capital of", "capitals.dat");

#include "questface.h"
#include "tvector.h"

class WhatsTheQuestion : public Question
{
  public:
    WhatsTheQuestion();
    WhatsTheQuestion(const string& prompt,
                     const string& filename);

    virtual bool   IsCorrect(const string& answer) const;
    virtual string Answer()                        const;
    virtual void   Ask()                           const;
    
    virtual void   Create();
    virtual void   Open(const string& prompt,
                        const string& filename);
    
  protected:
     struct Quest
     {
         string first;
         string second;
         Quest() {}     // need vector of Quests
         Quest(const string& f, const string& s)
           : first(f),
             second(s)
         {}
     };    
     tvector<Quest> myQuestions; // list of questions read
     string         myPrompt;    // prompt the user, "what's the ..."
     int            myQIndex;    // current question (index in myQuestions)
};

#endif

⌨️ 快捷键说明

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