Results 1 to 2 of 2
- 11-04-2012, 10:32 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Need some help on my if statment.
Hello, I need some help with my if statement.
I want to create a simple text base game.
The game begin with the character reaching the top floor of a castle and encounters the final boss. The character can has two choices, fight or kneel before the boss.
Right now if i type "fight" it display the following message, "You have decided to fight"
and if i type "knee" it will display the following "You have decided to join the Bloody Mistress"
How could i add an if statement into an if statement.
So if I type "fight" it display the following message, "You have decided to fight" followed by typing "axe" to display "You used your axe, your attack was avoided");
Can someone please help me!
Here are my codes:
Java Code:import java.util.Scanner; public class TxtG { public static String A = "fight"; public static String B = "axe"; public static String C = "kneel"; public static void main(String[] args) { Scanner x = new Scanner(System.in); System.out.println("You gave reached the 100th Floor of the Castle of Blood"); System.out.println("The Bloody Mistress awaits you at the center of the room"); System.out.println("Will you fight her?"); System.out.println("Or will you kneel before her?"); System.out.println("Choice: "); String i = x.nextLine(); if(i.equals(A)) { System.out.println("You have decided to fight"); if(A.equals(B)) { System.out.println("You used your axe, your attack was avoided"); } } else if(i.equals(C)) { System.out.println("You have decided to join the Bloody Mistress"); System.out.println("You will help her kill the Priestess of Hope"); } } }Last edited by quad64bit; 11-06-2012 at 04:17 PM. Reason: Formatting
- 11-06-2012, 04:19 PM #2
Re: Need some help on my if statment.
Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
I have added code tags for you.
This article might help you: The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
Similar Threads
-
if statment not working good
By nour in forum New To JavaReplies: 3Last Post: 03-25-2012, 09:29 PM -
Missing Return Statment, HELP PLEASE.
By dburgess in forum New To JavaReplies: 2Last Post: 06-05-2011, 07:40 PM -
If statment not working:(
By Harris68 in forum NetworkingReplies: 6Last Post: 02-24-2010, 10:41 PM -
statment replay!!!
By moamen in forum New To JavaReplies: 4Last Post: 09-25-2009, 12:49 PM -
Issue using FOR statment with NetBeans
By Deathmonger in forum Advanced JavaReplies: 3Last Post: 07-30-2008, 12:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks