Advertisement
Guest User

Untitled

a guest
Feb 5th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | Source Code | 0 0
  1. #ifndef SOLDIER_H
  2. #define SOLDIER_H
  3.  
  4. #include <QString>
  5.  
  6. /*
  7.  * All soldiers of the imperial army must know their rank.
  8.  * A soldier can be ordered to fight to the death, and no one but a soldier can receive such an order.
  9.  */
  10. class Soldier
  11. {
  12. private:
  13. protected:
  14.     QString rank;
  15.  
  16. public:
  17.     Soldier(QString assignedRank);
  18.     void Fight();
  19.     void sayRank();
  20. };
  21.  
  22.  
  23. /*
  24.  * Some soldiers are archers; all archers are soldiers
  25.  * Archers must know the number of arrows in their possession.
  26.  * An archer may be ordered to shoot a distant foe, and no one but an archer can receive such an order.
  27.  */
  28. class Archer : public Soldier
  29. {
  30. private:
  31. protected:
  32.     int arrowcount;
  33. public:
  34.     Archer(QString assignedRank, int assignedArrows);
  35.     void sayRank();
  36.     void Shoot();
  37. };
  38.  
  39.  
  40. /*
  41.  * Some soldiers are horsemen; all horseman are soldiers.
  42.  * Horsemen must know the horse that has been assigned to them.
  43.  * A horseman may be ordered to trample the enemies in his path, and no one but a horseman can receive such an order.
  44.  */
  45. class Horseman : public Soldier
  46. {
  47. private:
  48. protected:
  49. public:
  50.     QString horse;
  51.     Horseman(QString assignedRank, QString assignedHorse);
  52.     void sayRank();
  53.     void Trample();
  54. };
  55.  
  56. /*
  57.  * Some soldiers belong to the Flying Rain of Fire, whose members are both horsemen and archers in every respect.
  58.  * A member of the Flying Rain may be ordered to lead the charge, and no one but a member of the Flying Rain can receive such an order.
  59.  */
  60. class FROR : public Archer, public Horseman
  61. {
  62. private:
  63. protected:
  64. public:
  65.     FROR(QString assignedRank, int assignedArrows, QString assignedHorse);
  66.     void sayRank();
  67.     void Charge();
  68. };
  69. #endif // SOLDIER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement