Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant make the right code execute  RSS feed

 
Jonathan Arroyo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//Hello im have trouble when I enter in a choice it executes the wrong code please play through this game and you will see what im talking thank you
 
Liutauras Vilda
Marshal
Posts: 4638
316
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please tell us what you expect your program to do, and what actually it does, so someone could help you.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like it worked to me:

C:\slop>java HouseOfHorrors
Please enter your name.
fred
Welcome to the House of Horrors.
You will have five days to get out or you will become one of us.
fred: I only have five days to get out of this place, I dont even want to know who they are.
There is a door in front of you to get out but the door is locked.
There is a crowbar on the floor you can use to pry open the door
But there is also a key on the table along side of you that you can use to open the door.
What is choice choose wisley or it may cost you your life.
If you choose to use the crowbar enter A.
If you choose to use the key enter B.
a
You open the door the Alarm sounds you hear some of the inmats run to you.
You look for a place to hide you see a box in the corner that you can hide in.
But you also see a an open vent that you can hide in.
Make your choice but remember choose wisley because it may cost you your life.
If you choose to hide in the box on the corner then enter in C.
If you choose to hide in the open vent then enter in D.
c
fred: That was a close one I hope these inmats are not smart enough to check the under this box.
You drop something out of your pocket and makes a loud thomp noise.
The inmats hear it and turn toward the box and lift it up.
fred: SOMEONE PLEASE HELP ME!
Inmate: No one is here to help you now you will become one of us.
YOU LOSE
You have now been infected

C:\slop>
 
Liutauras Vilda
Marshal
Posts: 4638
316
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My best guess is that user of the program used CAPITAL cases instead lower cases.

Jonathan Arroyo, change choice.equals("c") to choise.equalsIgnoreCase("c") and do the same with other cases like this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!