Hi, I have to create a hunt the wumpus game using c++ and using the parameters that my proffesor set up, but I am really confused and I don't know where or what to start with. This are the parameters and other stuff that my proffesor gave us. (ps I cannot change this specifications).

#include <iostream>
#include <cstdlib>
using namespace std;

/*global constants*/

const int WHUMPUS = -1;                //global named constants for legibility
const int HERO = -2;
const int SWORD = -3;
const int CAVE_SIZE = 4;
const int NORTH = 1;
const int SOUTH = 2;
const int EAST = 3;
const int WEST = 4;

/*class declarations*/

class Room                             //class room represents a room in a cave
{
  private:
    bool has_whumpus;                  //private variables to store who and what
    bool has_hero;                     //is in the room
    bool has_sword;
    int x_location;                    //these will be the x and y coordinates of the rooom
    int y_location;                     //in the cave array
  public:
    void set_present(int item, bool flag);   //add or remove item from the room (ie. mutator
                                             //for private bool vars)
    bool check_present(int item);             //check if item is present (ie. accessor function
                                              //for items
    bool check_door(int direction);           //check if the door in this direction leads to
                                              //a room
    void set_location(int x, int y);          //set the room's coordinates in the cave array
    Room();                                   //room constructor
};\

class Agent                            //class agent represents a hero or the whumpus
{
  private:                  
    int type;                          //type specifies the the agent as the hero or the whumpus
    int x_location;                    //stores the array location of the agent
    int y_location;
  public:
    int get_type();                     //accessor
    void move(int direction);           //change the x and y location by moving in the
                                        //given direction
    int get_x_location();               //more accessors
    int get_y_location();
    Agent(int agent_type, int x_location, int y_location);  //constructor
};

/*global function*/

void output_cave(Room cave[][CAVE_SIZE]);  //code to print out the cave, don't need to change


/* Room member function definitions */
/* Implement these functions*/


void Room::set_present(int item, bool flag)
//set the bool var for item to value flag
{
}
bool Room::check_present(int item)
//return the value for item
{
}
bool Room::check_door(int direction)
//check if moving in "direction" would go out of bounds
{ 
}
void Room::set_location(int x, int y)
//set the x_location and y_location vars
{
}
int Agent::get_x_location()
//accessor
{
}
int Agent::get_y_location() 
//accessor
{
}
Room::Room()
{
  x_location = 0;
  y_location = 0;
  has_whumpus = false;
  has_hero = false;
  has_sword = false;
}

int Agent::get_type() 
//accessor
{
}
void Agent::move(int direction)
//move to a new room by changing the agents x_location and y_location
{
}
Agent::Agent(int agent_type, int x, int y)
{
  type = agent_type;
  x_location = x;
  y_location = y; 
}

void output_cave(Room cave[][CAVE_SIZE])
{
  cout<<endl<<endl;
  for (int i = 0; i<CAVE_SIZE; i++)
    {
      cout<<"\n[";
      for (int j = 0; j<CAVE_SIZE; j++)
      {
        if (cave[i][j].check_present(SWORD)) {cout<<"S";}
        else if (cave[i][j].check_present(HERO)) {cout<<"H";}
        else if (cave[i][j].check_present(WHUMPUS)) {cout<<"W";}
        else cout<<" * ";
      }
      cout<<"]";
    }
  cout<<endl<<endl;
}

int main()
{
 //initialize the cave, use an array of rooms
 //randomly place the sword, hero, and whumpus using the rand() function
 //loop untill the hero and whumpus or hero and sword are in the same room
 //need some way to keep track of if the hero has found the sword yet
}

Start by reading the code you've been given carefully and try to understand it (it would be too tedious to explain it here; consult your textbook). Then write a piece of the implementation (e.g., initialize the cave) and test it. Then write the next piece. Note that the cave is of type Room cave[][CAVE_SIZE] .

This article has been dead for over six months. Start a new discussion instead.