Skip to content

Instantly share code, notes, and snippets.

@reznor2006
Last active August 29, 2015 14:06
Show Gist options
  • Save reznor2006/db063766ba2c4a6e5e4b to your computer and use it in GitHub Desktop.
Save reznor2006/db063766ba2c4a6e5e4b to your computer and use it in GitHub Desktop.
#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;
}
@reznor2006
Copy link
Author

I couldn't figure out how to make player.getStat[str] pull strength, so I omitted the private ints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment