fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class playerCharacter{
  5. public:
  6. playerCharacter();
  7. playerCharacter(string, int, int, int, int, int, int, int, int);
  8. ~playerCharacter();
  9. string name;
  10. int strength;
  11. int dex;
  12. int intellect;
  13. int luck;
  14. int maxHp;
  15. int maxMp;
  16. int level;
  17. int experience;
  18. };
  19. playerCharacter::playerCharacter(){
  20. name = "blah";
  21. strength =0;
  22. dex =0;
  23. intellect =0;
  24. luck =0;
  25. maxHp =0;
  26. maxMp =0;
  27. level = 0;
  28. experience = 0;
  29.  
  30. }
  31. playerCharacter::playerCharacter(string cname, int s, int d, int i, int l , int maxh, int maxm, int exp, int levelset){
  32. name = cname;
  33. strength =s;
  34. dex =d;
  35. intellect =i;
  36. luck =l;
  37. maxHp =maxh;
  38. maxMp =maxm;
  39. level = levelset;
  40. experience = exp;
  41.  
  42. }
  43. playerCharacter::~playerCharacter(){
  44.  
  45. }
  46. void showClassMenu();
  47. void charAttrib(int []);
  48.  
  49. int main () {
  50.  
  51. string str ="";
  52. cout << "What would you like to name your character?: ";
  53. getline(cin, str);
  54.  
  55. showClassMenu();
  56. int mainArray[6];
  57. charAttrib(mainArray);
  58.  
  59. playerCharacter PC(str, mainArray[0], mainArray[1], mainArray[2], mainArray[3], mainArray[4], mainArray[5], 0, 1);
  60. cout << "\n\n";
  61. cout << "Character: " << PC.name <<endl <<"Strength: "<< PC.strength << endl;
  62. cout << "Dexterity: " << PC.dex <<endl << "Intellect: "<< PC.intellect <<endl;
  63. cout << "Max Health: "<< PC.maxHp << endl <<"Max mana: " << PC.maxMp<<endl;
  64. cout << "Experience: " << PC.experience <<endl;
  65. cout << "Level: "<< PC.level <<endl;
  66.  
  67. PC.experience +=1001;
  68. if (PC.experience > (PC.level*1000)){
  69. PC.level +=1;
  70. }
  71. cout << "Experience: " << PC.experience <<endl;
  72. cout << "Level: "<< PC.level <<endl;
  73.  
  74.  
  75. return 0;
  76. }
  77.  
  78. void showClassMenu(){
  79. cout << "\n\nWarrior, high strength, medium dexterity, low intellect, high hp, low mp, a war hardened hero. "<<endl;
  80. cout << "\nRanger, med strength, high dex, low intellect, med hp, low mp, a long range hero. "<<endl;
  81. cout << "\nMage, low strength, med dex, high intellect, low hp, high mp, an old man wise in the ways of magic. " << endl;
  82. cout << "Press 1 to make a warrior, press 2 to make a ranger, press 3 to make a mage"<<endl;
  83. }
  84.  
  85. void charAttrib(int mainArray[]){
  86.  
  87.  
  88. int select;
  89. cin >> select;
  90.  
  91. switch(select){
  92. case 1:{ //warrior
  93. mainArray[0] = 8; //str, dex, int, luck, hp, mp
  94. mainArray[1] = 5;
  95. mainArray[2] = 3;
  96. mainArray[3] = 5;
  97. mainArray[4] = 250;
  98. mainArray[5] = 70;
  99. break;
  100. }
  101. case 2:{
  102.  
  103. break;
  104. }
  105. case 3:{
  106.  
  107. break;
  108. }
  109.  
  110.  
  111.  
  112. }//End switch
  113.  
  114.  
  115.  
  116. }//end CharAttrib
  117.  
  118.  
Success #stdin #stdout 0s 2904KB
stdin
Standard input is empty
stdout
What would you like to name your character?: 

Warrior, high strength, medium dexterity, low intellect, high hp, low mp, a war hardened hero. 

Ranger, med strength, high dex, low intellect, med hp, low mp, a long range hero. 

Mage, low strength, med dex, high intellect, low hp, high mp, an old man wise in the ways of magic. 
Press 1 to make a warrior, press 2 to make a ranger, press 3 to make a mage


Character: 
Strength: 134523500
Dexterity: -1076962200
Intellect: 134516699
Max Health: 134523968
Max mana: 134523616
Experience: 0
Level:  1
Experience: 1001
Level:  2