I am trying to make a user choice based game that uses functions. this is biting off more than i can chew so to speak. I'd like to be able to show this to my teacher and impress him. Anyway, i'm i want to use the plains, forest, river, and mountain variables i declared in Geography(). I want to bring them into main() and use them. how do i do this?
cout<<"Your party approaches a plot of land surrounded by "<<endl;
cout<<"Plain(s) \t"<<plainsRan<<endl
<<"River(s)\t"<<riverRan<<endl
<<"Forest(s)\t"<<forestRan<<endl
<<"Mountain(s)\t"<<mountainRan<<endl;
cout<<"Would you like to start a settlement here?"<<endl;
}
int main()
{
names settlement;
int user_choice = 2;
while(user_choice != 1)
{
geography(1,2,3,4);
cout<<"[1] yes\n"
<<"[2] no\n";
cin>>user_choice;
system("clear"); //system clear needs to change to cls for windows
}
cout<<"what will you name your settlement?"<<endl;
cin.ignore();//flush the input to make getline work
getline(cin, settlement.Name);
system("clear"); //change to cls for windows
This is the first part of the game to establish the landscape. It will be like a civilization game that utilizes your geography's resources to make and build a thriving community.
> this code is way over my head so i'll have to study and understand it
This is functionally equivalent code; it does the same thing. But it is somewhat less C++-like; somewhat more like the kind of code that a career teacher would write. Perhaps having a look at this code would help in understanding the code as originally posted.