I can't figure out why I'm getting this error, i've checked all the posts I can find here and they are all a method inside another method, which i'm pretty sure I don't have.
This is the error message it gave me:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - illegal start of expression
at rps.Rps.compChoice(Rps.java:63)
at rps.Rps.main(Rps.java:20)
This is my code:
package rps;
import java.util.Random;
import java.util.Scanner;
public class Rps
{
Scanner keyboard =new Scanner(System.in);
Random rand = new Random();
public static void main(String[] args) {
String compType = "";
String playerType ="";
int comp = compChoice ();
int player = playerChoice ();
String winLose = choiceTree (player, comp);
if (comp == 1)
{
compType = "Rock.";
}
if (comp == 2)
{
compType = "Paper.";
}
if (comp == 3)
{
compType = "Scissors.";
}
if (player == 1)
{
playerType = "Rock";
}
if (player == 2)
{
playerType = "Paper";
}
if (player == 3)
{
playerType = "Scissors";
}
System.out.println ("You chose " + playerType + ", and the computer chose " + compType + " " + winLose);
}
public static int playerChoice ()
{
Scanner keyboard =new Scanner(System.in);
int choice = 0;
System.out.print("Rock(1), Paper(2), or Scissors(3)?: ");
choice = keyboard.nextInt();
}
public static int compChoice ()
{
Random rand = new Random();
int i = 0;
i = rand.nextInt(2) + 1;
return
}
public static String choiceTree (int player, int comp)
{
String answer = " ";
if (player == 1)
{
if (comp == 2)
{
answer = "You lose.";
}
if (comp == 3)
{
answer = "You win!";
}
}
if (player == 2)
{
if (comp == 1)
{
answer = "You win!";
}
if (comp == 3)
{
answer = "You lose.";
}
}
if (player == 3)
{
if (comp == 1)
{
answer = "You lose.";
}
if (comp == 2)
{
answer = "You win.";
}
}
else
{
}
}
}