Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
/* Code for LuckyDraw for boost for the player*/
#include <iostream>
#include <ctime>
using namespace std;
class luckyDraw
{
private:
int maxValue;
public:
luckyDraw(int maxValue = 6) // constructor
{
this->maxValue = maxValue;
}
~luckyDraw()
{
}
int spin(int times = 1)
{
int result = 0;
for (size_t i = 0; i < times; i++)
{
result += rand() % maxValue + 1;
}
return result;
}
};
int main()
{
srand(time(NULL)); // could use static_cast<unsigned>(0) instead of NULL
luckyDraw object;
cout << "You got: " << object.spin() << endl;
if (object.spin() == 1) {
cout << "You get a Health boost 10%!" << endl;
}
else if (object.spin() == 2) {
cout << "You get a attack boost by 10%!" << endl;
}
else if (object.spin() == 3) {
cout << "Your xp increases by 5%!" << endl;
}
else if (object.spin() == 4) {
cout << "You get a attack boost by 5%!" << endl;
}
else if (object.spin() == 5) {
cout << "You get a Health boost by 10%!" << endl;
}
else if (object.spin() == 6) {
cout << "Your xp increases by 10%!" << endl;
}
else {
cout << "Oh no! Looks like you get nothing!" << endl;
}
system("Pause");
return 0;
};