0

Was just wondering why my method (outcome) is off. It just outputs all of the syso() regardless of what is played. This is an incomplete program by the way, was just testing it before continuing. I was also concerned of any more efficient way to proceed writing the code. Im fairly new to coding so not looking for something too complicated. But mainly just trying to figure out why this outcome method is not working.

package main;
import java.util.Random;
import java.util.Scanner;

//Description: Create a program that plays rock, paper, scissors with the 
user then states who the winner is in the output

public class RPS
{

//Declaring variables
char playerMove, R, P, S;
int pcMoveNum;
String name, pcMove = "";
Scanner scan = new Scanner(System.in);
Random random = new Random();

public void input()
{
    System.out.println("Hello, whats your name?");
    name = scan.nextLine();
    System.out.println("Okay "+name+" lets play rock, paper scissors!");
    System.out.println("(R = rock, P = paper and S = scissors.)");
    System.out.println("Type R, P, or S to make your move");
    playerMove = scan.nextLine().charAt(0);
}


public void computerMove()
{
    pcMoveNum = random.nextInt(3)+1;

    if (pcMoveNum == 1);
    {
        pcMove = "R";
    }
    if (pcMoveNum == 2);
    {
        pcMove = "P";
    }

    if (pcMoveNum == 3);
    {
        pcMove = "S";
    }
}

public void outcome()
{
    if(playerMove == R); //Player chooses rock
    {
        if(pcMove == "R"); //If PC also chooses rock - use this output 
        {
            System.out.println("Its a Tie :I The computer choose rock and you choose rock.");
            if(pcMove == "P");
            {
                System.out.println("You Lose! :( The computer choose paper and you choose rock.");
                if(pcMove == "S");
                {
                    System.out.println("You Won :) The computer choose scissors and you choose rock.");
                }
            }
        }   
    }
}


public static void main(String[] args)
{
    RPS phill = new RPS();
    phill.input();
    phill.computerMove();
    phill.outcome();
}

}

0 Answers0