I have my code and i cant seem to figure out what im doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iostream>
#include <string>
#include <ctime>
#include <random>
#include <fstream>
using namespace std;
class CLASS
{
public:
void Player();
void TRex();
void Variables();
CLASS()
{
PHealth = 100;
TRHealth = 100;
}
private:
int PHealth;
int TRHealth;
};
int main()
{
CLASS CO;
CO.Variables();
string ready;
cout << "Welcome to the battle arena" << endl;
cout << "When you are ready please type in 'enter'" << endl;
cin >> ready;
if(ready == "Enter" || ready == "enter")
{
Player();
}
else
{
main();
}
}
void Variables()
{
int PHealth = 100; //Player Health
int TRHealth = 100; //T-Rex Health
}
void Player()
{
string choice;
cout << "What weapon will you use?" << endl;
cout << "\n";
cout << "1) Shotgun = 4 Damage" << endl;
cout << "2) Pistol = 2 Damage" << endl;
cout << "3) Knife = 2 Damage" << endl;
cout << "\n";
if(choice == "Shotgun" || choice == "shotgun")
{
TRHealth -= 4;
}
else if(choice == "Pistol" || choice == "pistol")
{
TRHealth -= 2;
}
else if(choice == "Knife" || choice == "knife")
{
TRHealth -= 2;
}
}
void TRex(int &PHealth, int &TRHealth)
{
time_t T;
time(&T);
srand(T);
int Time;
Time = rand() % 5;
switch(Time)
{
case 0:
cout << "T-Rex used Bite!" << endl;
cout << "-3 Health" << endl;
PHealth -= 3;
break;
case 1:
cout << "T-Rex used Chomp!" << endl;
cout << "-5 Health" << endl;
PHealth -= 5;
break;
case 2:
cout << "T-Rex used Stomp!" << endl;
cout << "-2 Health" << endl;
PHealth -= 2;
break;
default:
cout << "Trex's attack missed!" << endl;
PHealth -= 0;
}
switch(TRHealth)
{
case 0:
cout << "You have won!!" << endl;
break;
}
}
|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|38|error: 'Player' was not declared in this scope|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp||In function 'void Variables()':|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|48|warning: unused variable 'PHealth'|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|49|warning: unused variable 'TRHealth'|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp||In function 'void Player()':|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|65|error: 'TRHealth' was not declared in this scope|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|69|error: 'TRHealth' was not declared in this scope|
C:\Users\Chay Hawk\Desktop\Dinosaur Arena\main.cpp|73|error: 'TRHealth' was not declared in this scope|
||=== Build finished: 4 errors, 2 warnings ===|