Last active
August 29, 2015 14:06
-
-
Save reznor2006/db063766ba2c4a6e5e4b 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> | |
using namespace std; | |
class PlayerClass{ | |
private: | |
int str = 0; | |
int dex = 0; | |
int tech = 0; | |
char* 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 << "\nI am " << this->name; | |
} | |
void set_name(char* new_name){ | |
this->name = new_name; | |
} | |
}; | |
int main() | |
{ | |
PlayerClass player; | |
player.print_name(); | |
player.set_name("instance1"); | |
player.print_name(); | |
cin.ignore(); | |
PlayerClass homo; | |
homo.print_name(); | |
homo.set_name("instance2"); | |
homo.print_name(); | |
cin.ignore(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't figure out how to make player.getStat[str] pull strength, so I omitted the private ints.