Cannot find symbol variable - Why? I can.. ^^
Hello all
I'm trying to do a simple, not very good at all, tictactoe game, but, i got the error in one of the classes (This isn't while compiling the main file and classes)
Code:
C:\Documents and Settings\26462\Mina dokument\Inte skolsaker\1x2\Spelkod.java:27: cannot find symbol
symbol : variable BotPos
location: class Spelkod
I have no idea why this happens, i've tried to move the code "BotPos" from one to another class-file, and i don't have any more clues what's wrong, any help?
(Here is just one of the class-files, there are three, but the error is here somewhere)
Code:
import javax.swing.*;
import java.io.*;
import java.util.*;
public class Spelkod
{
public static void spel()
{
//Scanner som läser från kommandorutan
Scanner tangentbord = new Scanner(System.in);
String a1 = " ";
String a2 = " ";
String a3 = " ";
String b1 = " ";
String b2 = " ";
String b3 = " ";
String c1 = " ";
String c2 = " ";
String c3 = " ";
System.out.println("Where to put the X?");
String in = tangentbord.next();
Klasser.PassarRutval(in, a1, a2, a3, b1, b2, b3, c1, c2, c3);
[B]String botpos = Spelkod.BotPos;[/B]
while (true)
{
//Var ska botten sätta sin cirkel?
Klasser.PassarRutval(botpos, a1, a2, a3, b1, b2, b3, c1, c2, c3);
System.out.println("Where to put the X?");
in = tangentbord.next();
Klasser.PassarRutval(in, a1, a2, a3, b1, b2, b3, c1, c2, c3);
System.out.println("\n" + "_abc\n1:"+a1+b1+c1+"\n2:"+a2+b2+c2+"3:\n"+a3+b3+c3);
[B]botpos = Spelkod.BotPos;[/B]
}
}
[B]public static String BotPos ()[/B]
{
long numpos = Math.round(Math.random());
while (numpos<1 || numpos>3)
{
numpos = Math.round(Math.random());
}
long bokpos = Math.round(Math.random());
while (bokpos<1 || bokpos>3)
{
bokpos = Math.round(Math.random());
}
if (bokpos == 1)
return "a"+numpos;
else if (bokpos == 2)
return "b" + numpos;
else if (bokpos == 3)
return "c"+numpos;
else
{
System.exit(0);
return "null";
}
}
}
Yes, this is a very unfunctional code, but this is my first attemt ever to do something like this, so these are my first tries to a solution ;)
///Mattedatten