📄 capquest.cpp
字号:
#include <iostream>
#include <iomanip>
using namespace std;
#include "capquest.h"
#include "randgen.h"
#include "strutils.h"
Question::Question(const string& filename)
: myAnswer("*** error ***"),
myQuestion("*** error ***")
{
myIter.Open(filename.c_str());
}
void Question::Create()
{
RandGen gen;
int toSkip = gen.RandInt(0,49); // skip this many lines
int k;
myIter.Init();
for(k=0; k < toSkip; k++)
{ myIter.Next(); // skip the state
myIter.Next(); // and the capital
}
myQuestion = myIter.Current();
myIter.Next();
myAnswer = myIter.Current();
}
void Question::Ask() const
{
cout << "the capital of " << myQuestion << " is ";
}
bool Question::IsCorrect(const string& answer) const
{
return myAnswer == answer;
}
string Question::Answer() const
{
return myAnswer;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -