public class fermi
{
private int[] guess;
private int[] random;
private int total;
public fermi(int[] gs, int[] rn)
{
guess=new int[gs.length];
for(int i=0;i<gs.length;i++)
guess[i]=gs[i];
random=new int[rn.length];
for(int j=0;j<rn.length;j++)
guess[j]=gs[j];
total=0;
}
public int totalPlay()
{
return total+=1;
}
}
import javax.swing.JOptionPane;
import java.util.Random;
public class playFermi
{
public static void main(String [] args)
{
final int Num_Guess=3;
int [] guess=new int [Num_Guess];
String input;
char ch;
final int Num_Random=3;
int [] random=new int [Num_Random];
int quit;
int win=0;
int lose=0;
Random ran=new Random();
for(int j=0; j<random.length; j++)
{
random[j]=ran.nextInt(9);
}
input=JOptionPane.showInputDialog("Enter -1 to quit or else to play:");
quit=Integer.parseInt(input);
while(quit !=-1)
{
for(int i=0; i<guess.length; i++)
{
input=JOptionPane.showInputDialog("Enter your guess"+(i+1)+"(0-9):");
ch=input.charAt(0);
while(!Character.isDigit(ch))
{
input=JOptionPane.showInputDialog("Oops!Enter your guess"+(i+1)+"(0-9):");
ch=input.charAt(0);
}
guess[i]=Integer.parseInt(input);
while(guess[i]<0 || guess[i]>9)
{
input=JOptionPane.showInputDialog("Invalid number!!Please re-enter your guess "+(i+1)+"(0-9):");
ch=input.charAt(0);
while(!Character.isDigit(ch))
{
input=JOptionPane.showInputDialog("Oops!Enter your guess"+(i+1)+"(0-9):");
ch=input.charAt(0);
}
guess[i]=Integer.parseInt(input);
}
}
fermi give=new fermi(guess,random);
for(int k=0;k<3;k++)
{
if(guess[k]==random[0])
{
JOptionPane.showMessageDialog(null,"FERMI");
}
else if(guess[k]==random[1] || guess[k]==random[2])
{
JOptionPane.showMessageDialog(null,"PICO");
}
else
JOptionPane.showMessageDialog(null,"NANO");
}
if(guess[0]==random[0] && guess[1]==random[1] && guess[2]==random[2])
win+=1;
else
lose+=1;
input=JOptionPane.showInputDialog("Enter -1 to quit");
quit=Integer.parseInt(input);
give.totalPlay();
}
JOptionPane.showMessageDialog(null,"total play is "+give.totalPlay()+"\ntotal win is"+win+"\ntotal lose is"+lose);
}
}
i get an error said that cannot find symbol
symbol : variable give
what's wrong with my code?
pls help!
tq.