Permalink
Cannot retrieve contributors at this time
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?
Poojith-Patnala-s-Contribution/luckyDraw
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
80 lines (55 sloc)
1.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
}; |