This code never prints whether I win, lose, or it's a tie and I can't figure it out. I know hischoice and whichpick are both getting set correctly, but the ifs dont seem to work. Am I using Strings incorrectly or am I comparing them wrong? I am new to Java, so i'm not really sure what Im doing wrong.
import java.util.Scanner;
import java.util.Random;
public class rps {
public static void main(String[] args) {
int oppchoice;
String hischoice = "";
String whichpick;
String rock = "rock";
String paper = "paper";
String scissors = "scissors";
Scanner mS = new Scanner(System.in);
Random mR = new Random();
System.out.print("Type your choice (rock/paper/scissors): ");
whichpick = mS.nextLine();
oppchoice = mR.nextInt(3) + 1;
if (oppchoice == 1) {
hischoice = rock;
}
if (oppchoice == 2) {
hischoice = paper;
}
if (oppchoice == 3) {
hischoice = scissors;
}
System.out.println(hischoice);
if ((hischoice == rock) && (whichpick == paper)) {
System.out.println("You win! :)");
}
if ((hischoice == paper) && (whichpick == scissors)) {
System.out.println("You win! :)");
}
if ((hischoice == scissors) && (whichpick == rock)) {
System.out.println("You win! :)");
}
if ((hischoice == rock) && (whichpick == scissors)) {
System.out.println("You lose! :(");
}
if ((hischoice == paper) && (whichpick == rock)) {
System.out.println("You lose! :(");
}
if ((hischoice == scissors) && (whichpick == paper)) {
System.out.println("You lose! :(");
}
if ((hischoice == rock) && (whichpick == rock)) {
System.out.println("It's a tie! :|");
}
if ((hischoice == scissors) && (whichpick == scissors)) {
System.out.println("It's a tie! :|");
}
if ((hischoice == paper) && (whichpick == paper)) {
System.out.println("It's a tie! :|");
}
}
}