Build a Text Adventure Challenge Project (C++)

Congratulations on completing your project!

Compare your project to our solution code and share your project below! Your solution might not look exactly like ours, and that’s okay! The most important thing right now is to get your code working as it should (you can always refactor more later). There are multiple ways to complete these projects and you should exercise your creative abilities in doing so.

This is a safe space for you to ask questions about any sample solution code and share your work with others! Simply reply to this thread to get the conversation started. Feedback is a vital component in getting better with coding and all ability levels are welcome here, so don’t be shy!

About community guidelines: This is a supportive and kind community of people learning and developing their skills. All comments here are expected to keep to our community guidelines


How do I share my own solutions?

  • If you completed the project off-platform, you can upload your project to your own GitHub and share the public link on the relevant project topic.
  • If you completed the project in the Codecademy learning environment, use the share code link at the bottom of your code editor to create a gist, and then share that link here.

Do I really need to get set up on GitHub?
Yes! Both of these sharing methods require you to get set up on GitHub, and trust us, it’s worth your time. Here’s why:

  1. Once you have your project in GitHub, you’ll be able to share proof of your work with potential employers, and link out to it on your CV.
  2. It’s a great opportunity to get your feet wet using a development tool that tech workers use on the job, every day.

Not sure how to get started? We’ve got you covered - read this article for the easiest way to get set up on GitHub.

Best practices for asking questions about the sample solution

  • Be specific! Reference exact line numbers and syntax so others are able to identify the area of the code you have questions about.
1 Like

First time on github not sure if im linking this correctly

1 Like

Got a bit carried away; made the whole thing modular for future development so made the Player and Locations Classes to practice.

Really proud of it as my third ever C++ program, still confused as to why I can’t seem to loop over an array of class objects and activate their methods but I will figure it out.

1 Like
1 Like
1 Like

#include

int main(){

int choice,choice2,choice3,choice4;

std::cout<<"Welcome to the trip.\n You just exit your home. \n To which direction do you walk ? \n 1) Left \n 2) Right\n Answer= ";

std::cin >> choice;

if (choice==1){

std::cout<<"You have found your best friend on the way ! \n He proposes you to go to the cinema. Do you go with him ?\n 1)Yes\n 2) No\n Answer=";

std::cin>>choice2;

if (choice2==1){

  std::cout<<"Great! You stayed the whole day watching a film! \n The game has ended";

}

else if (choice2==2){

  std::cout<<"You failed ! \n You stay in the street and get eaten by dinausors. \n The game has ended";}

else {std::cout<<"You have given an invalid answer";}

}

else if (choice==2){

std::cout<<"You have found an Apple tree. \n What do you do ? \n 1) You eat an Apple \n 2) You don't eat an Apple\n Answer=";

std::cin>>choice2;

if (choice2==1){

  std::cout<<"A Mars citizen comes to meet you\n Do you choose to talk to him ? \n 1) Yes \n 2)No \n Answer=";

  std::cin>>choice3;

  if (choice3==1){

    std::cout<<"You go with him to march. Amazing ! \n The game has ended";}

  else if (choice3==2){

    std::cout<<"He leaves to Mars and you come back home. \n The game has ended";

  }

  }

else if (choice2==2){

std::cout<<"You have found your best friend on the way ! \n He proposes you to go to the cinema. Do you go with him ?\n 1)Yes\n 2) No\n Answer=";

std::cin>>choice4;

if (choice4==1){

  std::cout<<"Great! You stayed the whole day watching a film! \n The game has ended";

}

else if (choice4==2){

  std::cout<<"You failed !\nYou stay in the street and get eaten by dinausors. \n The game has ended";}

else {std::cout<<"You have given an invalid answer";}

}

else {

std::cout<<"You have given an invalid answer\n";

}

}

}