This site is retired and is no longer updated since November 2021. Please visit our new website at https://www.teamscode.org for up-to-date information!
Coding Challenge #1

Welcome to your first coding challenge! This is an optional challenge you can complete in order to improve your understanding of the first nineteen lessons. The purpose of this coding challenge is to create a Text Adventure game!

Text Adventure games were some of the first popular games for computers. Although Text Adventure games can be improved using methods and classes, you will be making a very simple but fun Text Adventure game using print statements, the Scanner class, the Math class, if statements, while loops, and some simple variables.

In a Text Adventure game, the print statements provide the player with a description of where they are and what options they have. The Scanner class is used to accept player input and therefore direct the game (remember to import this class or the program won’t run). If statements are used to create different scenarios based on user input. While loops are used to repeat a specific scenario until a certain requirement is met. The Math class is used to add randomness to the game. Finally, variables provide the player with their health, choice of weapons, and more.

Below is a .java file of an already-made Text Adventure game. Run the main method of the below file to see how a Text Adventure game works as well as to learn how to create your own Text Adventure game.

TextAdventure.java

Good luck!

Written by Chris Elliott

Notice any mistakes? Please email us at learn@teamscode.com so that we can fix any inaccuracies.