Thanks, that got it working, but now I've added more code and its not working right again.
The cout statements in object::noticed should should change between 1 and 0 whenever you call case 93, but they never change. Am I not passing the values correctly within the classes? and should I be using a pointer somewhere?
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
extern "C"
{
extern int get_input_line(char* verb, char* DO, int &link, char* io);
extern void endgame();
}
class object
{
private:
char name[20];
int where; // Where object is, -1 if carried
int seen; // If you have seen it
int have; // If you have it
int room;
public:
int setup(char n[20], int w, int s, int h);
int get(int room);
int noticed(int room);
};
int object::setup(char n[20], int w, int s, int h)
{
strcpy(name, n);
where = w;
seen = s;
have = h;
return have;
return seen;
}
int object::get(int room)
{
cout<<seen<<endl;
cout<<have<<endl;
if (((room == where) || (where == -1)) && (seen == 1) && (have == 0))
{
cout<< "You have picked up the "<< name <<"."<<endl;
have = 1;
return have;
}
else if (((room == where) || (where == -1)) && (seen != 1) && (have == 0))
// else if (seen != 1)
{
cout << "There does not seem to be a " << name
<< " anywhere." <<endl;
return 0;
}
else if (((room == where) || (where == -1)) && (seen == 1) && (have == 1))
// else if (have == 1)
{
cout<< "You already have the "<< name <<"."<<endl;
return 1;
}
else
{
cout<<"You cannot get the "<< name <<"."<<endl;
return 0;
}
}
int object::noticed(int room)
{
cout<<seen<<endl;
if (seen == 0)
{
cout<<"You notice a "<<name<<"."<<endl;
seen = 1;
cout<<"seen "<<seen<<endl;
return seen;
}
else
{
cout<<"You don't see anything"<<endl;
return 1;
}
}
int room1(int array[100])
{
char verbST[100];
char IO[100];
char DO[100];
int link;
int verb;
object can;
int room = 0;
int seenit = 0;
int haveit = 0;
can.setup("can", room, seenit, haveit);
verb = get_input_line(verbST, DO, link, IO);
//itemnum = cvt(DO);
switch (verb)
{
case 93:
can.setup("can", 1, seenit, haveit);
seenit = can.noticed(1);
//cout<<seenit<<endl;
break;
case 50:
can.setup("can", 1, seenit, haveit);
haveit = can.get(1);
break;
default:
cout << " You can't do that!" << endl;
return 1;
}
return 1;
}
main ()
{
int room;
int array[100];
room = 1;
cout<<endl<<endl;
cout<<" --==]==[ Title ]==[==--" <<endl<<endl;
srandom(time(NULL));
while (room < 5)
{
cout << endl << endl;
switch (room)
{
case 1:
room = room1(array);
break;
}
}
}