Difference between revisions of "The Labyrinth"

From CompSciWiki
Jump to: navigation, search
Line 1: Line 1:
 
{{1010PrAD|ProblemName=The Labyrinth
 
{{1010PrAD|ProblemName=The Labyrinth
  
|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.  To complete this problem, you should have a good understanding of [[Control_Structures|Nested if statements]] as well as [[JOptionPane_Methods|JOptionPane Methods]].Design the labyrinth exactly as described below:
+
|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.  To complete this problem, you should have a good understanding of [[Control_Structures|Nested if statements]] as well as [[JOptionPane_Methods|JOptionPane Methods]]. Design the labyrinth exactly as described below:
  
  

Revision as of 16:49, 3 April 2010

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. To complete this problem, you should have a good understanding of Nested if statements as well as JOptionPane Methods. 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 contained in a cage. There are two buttons: One button opens the cage, one button undoubtably seals your doom. Choose your fate: 1. Left button 2. Right button


Choice 1:


Output Dialog: A trap door opens up beneath you and you fall into a pit of spikes and die. Game Over.


Choice 2:


Output Dialog: The cage opens. The treasure is yours. Congratulations!

 

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