📄 capquest.h
字号:
#ifndef _STATEQUEST_H
#define _STATEQUEST_H
// ask a question involving state capitals
// This class conforms to the naming conventions
// of quiz questions in "A Computer Science Tapestry" 2e
//
// This question quiz for state capitals requires construction
// with the name of a data file in the format below
//
// state capital (one pair per line, use '_' instead of ' 'e.g.)
//
// New_York Albany
// Kentucky Frankfort
// Minnesota Saint_Paul
//
// there should be 50 lines in the data file
//
// this convention requires the following functions:
//
// void Create()
// -- ask a new question
// void Ask() const
// -- ask the last question (from Create()) again
//
// bool IsCorrect(const string& answer) const
// -- return true iff answer is correct to last (Create()) question
// string Answer() const
// -- return the answer to the last (Create()) question
//
#include <string>
#include "worditer.h"
using namespace std;
class Question
{
public:
Question(const string& filename);
bool IsCorrect(const string& answer) const;
string Answer() const;
void Ask() const;
void Create(); // create a new question
private:
string myAnswer; // answer (state capital)
string myQuestion; // the state
WordStreamIterator myIter; // iterates over file of states/capitals
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -