mathquestface.h

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 50 行

H
50
字号
#ifndef _MATHQUESTFACE_H
#define _MATHQUESTFACE_H

// quiz questions involving arithmetic (addition)
// see comments in questface.h for the naming conventions
// used in quiz classes
//
// MathQuestion()      -- no carry involved, two-digit numbers
// CarryMathQuestion() -- does have carry, two-digit numbers
// HardMathQuestion()  -- three digit addition
//
// these classes add method Description() to the question hierarchy

#include "questface.h"

class MathQuestion : public Question
{
  public:
    MathQuestion();
    virtual bool   IsCorrect(const string& answer) const;
    virtual string Answer()                        const;
    virtual void   Ask()                           const;   
    virtual string Description()                   const;
    
    virtual void Create();  // create a new question
             
  protected:
    string myAnswer;  // store the answer as a string here
    int myNum1;       // numbers used in question
    int myNum2;
};

class CarryMathQuestion : public MathQuestion
{
  public:
    CarryMathQuestion();
    virtual string Description()  const;
    virtual void   Create(); 
};

class HardMathQuestion : public MathQuestion
{
  public:
    HardMathQuestion();
    virtual string Description()  const;
    virtual void   Create();   
};

#endif

⌨️ 快捷键说明

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