Skip to content

Instantly share code, notes, and snippets.

@aznnico
Forked from reznor2006/gist:db063766ba2c4a6e5e4b
Last active August 29, 2015 14:06
Show Gist options
  • Save aznnico/56788f38a821e74b7f62 to your computer and use it in GitHub Desktop.
Save aznnico/56788f38a821e74b7f62 to your computer and use it in GitHub Desktop.
#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