import java.util.Scanner;
public class ShopSystem
{
public static void main (String [] args)
{
String plyrRace; int plyrRaceI;
System.out.println("What is your race?");
System.out.println("Orc");
System.out.println("Elf");
System.out.println("Human");
Scanner scan = new Scanner(System.in);
String userString = scan.next();
if (userString.equalsIgnoreCase("orc"));
{
plyrRace = "orc";
plyrRaceI = 0;
System.out.println("You've chosen orc!");
}
else if (userString.equalsIgnoreCase("elf"));
{
plyrRace = "elf";
plyrRaceI = 1;
System.out.println("You've chosen elf!");
}
else if (userString.equalsIgnoreCase("human"));
{
plyrRace = "human";
plyrRaceI = 2;
System.out.println("You've chosen human!");
}
else
{
System.out.println("That is not a valid race; pick again.");
}
}
}
Helping my friend code a game
, I was trying to work on an expansive shop system
, which I needed races for. I wasn't able to use the else
or else if
statements without an error. I have no idea why I can't get the else statements
to work. Any help would be amazing, as I'm new to Java.