Jump to content

Hunt The Wumpus/C++: Difference between revisions

m
no edit summary
m ({{collection|Hunt_The_Wumpus}})
mNo edit summary
Line 16:
MAX_ROOMS = 20, SAVED = 6, MAX_EXITS = 3, A_PATH_LEN = 5, MAX_ARROWS = 5;
 
class inOut
{
public:
int getLetter( std::string s, int a, int b )
{
int c;
do
{
msg( s );
std::string r; std::cin >> r;
std::cin.clear(); std::cin.ignore();
c = toupper( r[0] );
}
while( c != a && c != b );
 
return c;
}
 
int getNumber( std::string s )
{
int n = 0; std::string c;
while( true )
{
msg( s );
std::getline( std::cin, c );
std::stringstream strm( c );
if( strm >> n ) break;
}
return n;
}
 
void msg( std::string s ) { std::cout << s; }
void msg( int i ) { std::cout << i; }
void wait() { std::cin.get(); }
};
 
class room
{
public:
int getExit( int i ) { return exits[i]; }
byte contains() { return obj; }
void clear( object o ) { obj ^= o; }
void clearRoom() { obj = NOTHING; }
void setExit( int i, int e ) { exits[i] = e; }
void populate( object o ) { obj |= o; }
 
 
private:
int exits[MAX_EXITS];
byte obj;
};
 
class cave
Cookies help us deliver our services. By using our services, you agree to our use of cookies.