-
-
Save aznnico/56788f38a821e74b7f62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
#include <string> | |
using namespace std; | |
class PlayerClass{ | |
private: | |
int str = 0; | |
int dex = 0; | |
int tech = 0; | |
string name = "default"; | |
void rollStats(){ | |
srand (unsigned(time(NULL))); | |
//Sleep(500); | |
this->str = rand()%6+10; | |
this->dex = rand()%6+10; | |
this->tech = rand()%6+10; | |
} | |
public: | |
void run(){ | |
do{ | |
cout << "\n Rerolling..." << endl; | |
this->rollStats(); | |
cout << "\n Str: " << this->str; | |
cout << "\n Dex: " << this->dex; | |
cout << "\n Tech: " << this->tech; | |
cout << "\n\n Press any key to reroll."; | |
} while(cin.ignore()); | |
} | |
void print_name(){ cout << "i am " << this->name; } | |
void set_name(string new_name){ this->name = new_name; } | |
}; | |
int main() | |
{ | |
PlayerClass player; | |
player.print_name(); | |
player.set_name("instance1"); | |
player.print_name(); | |
PlayerClass homo; | |
player.print_name(); | |
player.set_name("instance2"); | |
player.print_name(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment