Advertisement
Guest User

alreadyDefined&wrongInputInfLoop

a guest
Feb 13th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. //1: Here is Mainirk.cpp
  4.  
  5. #include <windows.h>
  6. #include "include/irrKlang.h"
  7. #include <conio.h>
  8. #include "stats.h"
  9.  
  10. #pragma comment(lib, "irrKlang.lib")
  11. using namespace std;
  12. using namespace irrklang;
  13.  
  14.  
  15. int choose();
  16. void charmander1();
  17. void bulbasaur1();
  18. void squirtle1();
  19. void yourpokemon();
  20. void enemypokemon();
  21. void battle();
  22. void bchoice();
  23. void aichoice();
  24.  
  25. void attack();
  26. void defend();
  27. double y;
  28. double z;
  29.  
  30.  
  31. double m;
  32. double n;
  33.  
  34. int achoice;
  35.  
  36.  
  37. pokemon charmander (25,3);
  38. pokemon bulbasaur (20,4);
  39. pokemon squirtle (30,2);
  40.  
  41.  
  42.  
  43. int main()
  44. {
  45. choose();
  46. yourpokemon();
  47. cout<<"\nPress any key to continue.";
  48. _getch();
  49. system("cls");
  50. cout<<"Your rival Chuy walks in and challenges you to a battle\n\n";
  51. _getch();
  52.  
  53. do
  54. {
  55. battle();
  56. aichoice();
  57. _getch();
  58. }
  59. while (y>0 && m>0);
  60.  
  61. return 0;
  62. }
  63.  
  64.  
  65.  
  66.  
  67. int choose()
  68. {
  69.  
  70. cout<<"Choose your pokemon!!!\n\n";
  71. cout<<"********************************\n\n";
  72. cout<<" Charmander has "<<charmander.hp()<<" hp and "<<charmander.dmg()<<" damage.\n\n";
  73.  
  74. cout<<" Bulbasaur has "<<bulbasaur.hp()<<" hp and "<<bulbasaur.dmg()<<" damage.\n\n";
  75.  
  76. cout<<" Squirtle has "<<squirtle.hp()<<" hp and "<<squirtle.dmg()<<" damage.\n\n";
  77. cout<<"--------------------------------\n\n";
  78.  
  79. cout<<"Type [a] to choose Charmander\n\n";
  80.  
  81. cout<<"Type [b] to choose Bulbasaur\n\n";
  82.  
  83. cout<<"Type [c] to choose Squirtle\n\n";
  84. char answer;
  85. cin>>answer;
  86.  
  87.  
  88. if (answer == 'a'||answer == 'A')
  89. {
  90. answer = 'a';
  91. }
  92.  
  93. if (answer == 'b'||answer == 'B')
  94. {
  95. answer = 'b';
  96. }
  97.  
  98. if (answer == 'c'||answer == 'C')
  99. {
  100. answer = 'c';
  101. }
  102.  
  103.  
  104.  
  105. switch (answer)
  106. {
  107. if (answer =='a')
  108. {
  109. case 'a': charmander1();
  110. y= charmander.hp();
  111. z= charmander.dmg();
  112. m= squirtle.hp();
  113. n= squirtle.dmg();
  114. }
  115. if (answer == 'b')
  116. {
  117. case 'b': bulbasaur1();
  118. y = bulbasaur.hp();
  119. z = bulbasaur.dmg();
  120. m = charmander.hp();
  121. n = charmander.dmg();
  122. }
  123. if (answer == 'c')
  124. {
  125. case 'c': squirtle1();
  126. y = squirtle.hp();
  127. z = squirtle.dmg();
  128. m = bulbasaur.hp();
  129. n = bulbasaur.dmg();
  130. }
  131. }return 0;
  132. }
  133.  
  134. void charmander1()
  135. {
  136. cout<<"You have chosen the Pokemon Charmander!!!\n";
  137. cout<<"Charmander is a fire type!\n";
  138. }
  139.  
  140. void bulbasaur1()
  141. {
  142. cout<<"You have chosen the Pokemon Bulbasaur!!!\n";
  143. cout<<"Bulbasaur is a grass type!\n";
  144. }
  145.  
  146. void squirtle1()
  147. {
  148. cout<<"You have chosen the Pokemon Squirtle!!!\n";
  149. cout<<"Squirtle is a water type!\n";
  150. }
  151.  
  152. void yourpokemon()
  153. {
  154.  
  155. cout<<"HP is "<<y<<" and damage is "<<z;
  156. }
  157.  
  158.  
  159.  
  160. void battle()
  161. {
  162. cout<<"\n\t\tStatus\t\t";
  163. cout<<"\n-----------------------\n";
  164. cout<<"Your Pokemon\t\tEnemy Pokemon\n";
  165. cout<<"HP: "<<y<<"\t\tHP: "<<m<<"\n";
  166. ISoundEngine* se = createIrrKlangDevice();
  167. se->play2D("Kalimba.mp3");
  168.  
  169.  
  170. bchoice();
  171. }
  172.  
  173. void bchoice()
  174. {
  175. cout<<"\n\nType 1 to attack or 2 to defend\n";
  176.  
  177. cin>>achoice;
  178.  
  179. if (achoice ==1)
  180. {
  181. attack();
  182. }
  183. else if (achoice ==2)
  184. {
  185. defend();
  186. }
  187. else
  188. {
  189. cout<<"Retype your choice"<<endl;
  190.  
  191. }
  192. }
  193.  
  194. void attack()
  195. {
  196. m = m-z;
  197. cout<<"\nYour Pokemon attacks!";
  198. }
  199.  
  200. void defend()
  201. {
  202. cout<<"\nYour pokemon defends!";
  203. }
  204.  
  205.  
  206.  
  207. void aichoice()
  208. {
  209. if (achoice ==1)
  210. {
  211. cout<<"\nThe enemy pokemon attacks!";
  212. y = (y-n);
  213. }
  214.  
  215.  
  216. else if (achoice ==2)
  217. {
  218. cout<<"\nThe enemy pokemon defends!";
  219. }
  220. }
  221.  
  222.  
  223.  
  224. // 2. Here is stats.h
  225.  
  226. #include <iostream>
  227. using namespace std;
  228.  
  229. class pokemon
  230. {
  231. int health, damage;
  232.  
  233. public:
  234.  
  235. pokemon (int,int);
  236. int hp()
  237. {
  238. return (health);
  239. }
  240.  
  241. int dmg()
  242. {
  243. return (damage);
  244. }
  245.  
  246. };
  247.  
  248. pokemon::pokemon (int hp, int dmg)
  249. {
  250. health = hp;
  251. damage = dmg;
  252. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement