threw together a quick example of your code with classes. I still reccomend you revise the logic and how you do things in it, but see how much neater and (for the most part) clearer this is? If there is anything you don't understand were more than glad to help/improve on it. The most important thing in C++ is to never give up and never stop learning.
Code:
#include <iostream.h>
#include <stdlib.h>
class Actions
{
public:
float health();
float attack();
float defense();
float spider();
private:
float x,
y,
a,
Health,
Defense,
Spider;
};
int main()
{
Actions Object;
cout << "Welcome to the Battle Arena!" << endl;
Object.health();
Object.attack();
Object.defense();
Object.spider();
return 0;
}
float Actions::health()
{
x = 1 + rand() % 5;
if (x >= 20)
{
return 15;
}
else
{
return x;
}
cout << "Your starting Health is: " << Health << endl;
}
float Actions::defense()
{
y = 5 + rand();
if (y > 20)
{
return y;
}
else
{
return 20;
}
cout << "Your starting Defense is: " << Defense << endl;
cout << "Your first Enemy is the poison Spider!" << endl;
}
float Actions::spider()
{
a = 5 + rand();
if (a > 10)
{
return 7;
}
else
{
return 5;
}
cout << "Spider's Health is: " << Spider << endl;
cout << "Attack? " << endl;
}