Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- void hp(int base);
- void attack(int base);
- void defense(int base);
- void speed(int base);
- int main(){
- //Assignment: Create a unique function.
- //Challenge: Calculate stats in other functions and return them.
- srand(time(0));
- int base_stat = 0;
- do{
- std::cout << "Enter in a base stat (0-50): ";
- std::cin >> base_stat;
- if(base_stat > 50 || base_stat <= 0){
- std::cout << "Stat not in range! ";
- base_stat = 0;
- }
- }while (base_stat == 0);
- std::cout << "Stats\n";
- hp(base_stat);
- attack(base_stat);
- defense(base_stat);
- speed(base_stat);
- return 0;
- }
- void hp(int base){
- base;
- int hp = rand() % 11 + base + 30;
- std::cout << "HP: " << hp << '\n';
- }
- void attack(int base){
- base;
- int attack = rand() % 11 + base;
- std::cout << "Attack: " << attack << '\n';
- }
- void defense(int base){
- base;
- int defense = rand() % 11 + base;
- std::cout << "Defense: " << defense << '\n';
- }
- void speed(int base){
- base;
- int speed = rand() % 11 + base;
- std::cout << "Speed: " << speed << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement