Advertisement
OMEGAHEAD_MonkoX

Untitled

Dec 10th, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Character
  7. {
  8. protected:
  9. int constitution;
  10. int intelligence;
  11. int health;
  12. public:
  13. Character(int c, int i);
  14. int get_health();
  15. virtual int get_max_health();
  16. int get_max_load();
  17. virtual string class_name() {
  18. return "Character";
  19. };
  20. virtual void display(){
  21. cout << "Character" << " " ;
  22. cout << get_health() << endl;
  23. }
  24. };
  25.  
  26. Character::Character(int c, int i)
  27. {
  28. constitution = c;
  29. intelligence = i;
  30.  
  31. health = 10 + constitution;
  32. }
  33.  
  34. int Character::get_health()
  35. {
  36. return health;
  37. }
  38.  
  39.  
  40. int Character::get_max_health()
  41. {
  42. return health;
  43. }
  44.  
  45.  
  46. int Character::get_max_load()
  47. {
  48. return (2 * constitution);
  49. }
  50.  
  51. class Wizard:public Character
  52. {
  53. protected:
  54. int spell_level;
  55. public:
  56. int get_health();
  57. int get_max_load();
  58. int get_max_spell_level();
  59. virtual int get_max_health();
  60. virtual string class_name() {
  61. return "Wizard";
  62. };
  63. virtual void display(){
  64. cout << "Wizard" <<" " ;
  65. cout << get_health() << endl;
  66. }
  67. Wizard(int c, int i);
  68. };
  69.  
  70. Wizard::Wizard(int c, int i) :Wizard::Character(c, i) {
  71.  
  72. constitution = c;
  73. intelligence = i;
  74.  
  75. health = 20 + constitution;
  76. if (intelligence - 10 >= 0)
  77. spell_level = intelligence - 10;
  78. else
  79. spell_level = 0;
  80. }
  81.  
  82. int Wizard::get_health()
  83. {
  84. return health;
  85. }
  86.  
  87. int Wizard::get_max_health()
  88. {
  89. health = 20 + constitution;
  90. return (20 + constitution);
  91. }
  92.  
  93.  
  94. int Wizard::get_max_load()
  95. {
  96. return (2 * constitution);
  97. }
  98. int Wizard::get_max_spell_level()
  99. {
  100. return spell_level;
  101. }
  102. class Fighter:public Character
  103. {
  104. private:
  105. int feats;
  106. public:
  107. int get_health();
  108. int get_max_load();
  109. int get_feats();
  110. virtual int get_max_health();
  111. virtual string class_name() {
  112. return "Fighter";
  113. };
  114. virtual void display(){
  115. cout << "Fighter" <<" ";
  116. cout << get_health()<<endl;
  117. }
  118. Fighter(int c, int i);
  119. };
  120.  
  121. Fighter::Fighter(int c, int i) :Fighter::Character(c, i) {
  122. constitution = c;
  123. intelligence = i;
  124.  
  125. health = 22 + constitution;
  126. feats = constitution / 3;
  127. }
  128.  
  129. int Fighter::get_health()
  130. {
  131. return health;
  132. }
  133.  
  134. int Fighter::get_max_health()
  135. {
  136. return health;
  137. }
  138.  
  139.  
  140. int Fighter::get_max_load()
  141. {
  142. return (3 * constitution);
  143. }
  144. int Fighter::get_feats()
  145. {
  146. return feats;
  147. }
  148. class WizardSpecialist:public Wizard
  149. {
  150. private:
  151. int school;
  152. int opposed_school;
  153. public:
  154. int get_health();
  155. int get_max_load();
  156. int get_school();
  157. int get_opposed_school();
  158. virtual int get_max_health();
  159. int get_max_spell_level();
  160. virtual string class_name() {
  161. return "WizardSpecialist";
  162. };
  163. WizardSpecialist(int c, int i, int d);
  164. virtual void display(){
  165. cout << "WizardSpecialist" <<" ";
  166. cout << get_health() <<endl;
  167. }
  168. };
  169.  
  170. WizardSpecialist::WizardSpecialist(int c, int i, int d) :WizardSpecialist::Wizard(c, i) {
  171. constitution = c;
  172. intelligence = i;
  173. health = 20 + constitution;
  174. if (intelligence - 10 >= 0)
  175. spell_level = intelligence - 10;
  176. else
  177. spell_level = 0;
  178. school = d;
  179. if (school > 4)
  180. opposed_school = d - 4;
  181. else
  182. opposed_school = d + 4;
  183. }
  184.  
  185. int WizardSpecialist::get_health()
  186. {
  187. return health;
  188. }
  189.  
  190. int WizardSpecialist::get_max_health()
  191. {
  192. health = 20 + constitution;
  193. return (20 + constitution);
  194. }
  195.  
  196.  
  197. int WizardSpecialist::get_max_load()
  198. {
  199. return ( constitution / 2);
  200. }
  201. int WizardSpecialist::get_max_spell_level()
  202. {
  203. return spell_level;
  204. }
  205. int WizardSpecialist::get_school(){
  206. return school;
  207. }
  208. int WizardSpecialist::get_opposed_school(){
  209. return opposed_school;
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement