Created
June 25, 2012 23:22
-
-
Save johnhamelink/2992067 to your computer and use it in GitHub Desktop.
This file contains 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
#ifndef HAND_H | |
#define HAND_H | |
// For IO | |
#include <iostream> | |
#include <string> | |
// For random | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
using namespace std; | |
class hand | |
{ | |
public: | |
hand(); | |
~hand(){}; | |
string getType() { return type[0]; }; | |
protected: | |
string type[3]; | |
int random; | |
}; | |
hand::hand() | |
{ | |
string types[3][3] = { | |
{ "rock", "paper", "scissors" }, | |
{ "paper", "scissors", "rock" }, | |
{ "scissors", "paper", "rock" } | |
}; | |
// Initialise with a random seed | |
srand ( time(NULL) ); | |
// Random number from 0 to 2 | |
random = rand() % 3; | |
type = types[random]; | |
} | |
#endif |
This file contains 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 <string>; | |
#include <iostream>; | |
using namespace std; | |
#include "hand.h"; | |
#include "player.h"; | |
int main(int argc, const char *argv[]) | |
{ | |
hand h; | |
cout<<h.getType()<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I compile with G++ I get the following: