The Labyrinth

From CompSciWiki
Revision as of 16:17, 3 April 2010 by TylerD (Talk | contribs)

Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

For this problem, you will create a labyrinth. The user will be given a series of decisions to make in hope of making it to the treasure. For the simplicity sake, the labyrinth will very small. The input will be recorded using JOptionPane.showInputDialog and the output will be done with JOptionPane.showMessageDialog. The user will enter an integer based on their choice. If the user makes the wrong choice, the game will be over and the program will end. Design the labyrinth exactly as described below:

Input Dialog: You have arrived at the entrance of the labyrinth. Large doors stand in front of you. A wooden sign reads "Death Awaits". Choose your fate: 1. Go inside 2. Leave

Choice 2:

Output Dialog: Before you can leave, a hungry tiger attacks and kills you. Game Over.

Choice 1:

Input Dialog: You enter the labyrinth, well aware that your life may be in jeopardy. Almost instantly your suspicions are confirmed. There are two doors with two dragons guarding them. One dragon is good, one is evil. Choose your fate: 1. Red dragon 2. Blue dragon.

Choice 2:

Output Dialog: The blue dragon claws your face off. You need that to live. Game Over.

Choice 1:

Input Dialog: The red dragon likes your style. He moves out of the way and allows you to enter his door. You walk into the next room. In the distance you see what you came here for, the treasure. Unfortunately the treasure is guarded by

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

Code

Solution Code

Back to the Program-A-Day homepage