Hello
I cant figure out how to recive a boolean from a method in another class.
public boolean arYatzy() {
boolean yatzy = true;
for (int i = 0; i < tarn.length - 1; i++) {
yatzy = yatzy && (tarn[i] == tarn[i + 1]);
}
if (yatzy) {
return true;
}
else {
return false;
}
}
public static void main(String[] args){
Yatzy y2 = new Yatzy();
int[] t2 = new int[5];
int ggr=0;
int antal=0;
System.out.println("loop");
boolean varv = true;
long startTid = System.currentTimeMillis();
do{
for(int i=0; i < t2.length; i++)
{
t2[i] = 1 + (int) ((6 - 1 + 1) * Math.random());
}
if(y2.arYatzy()==true){
antal++;
}
else if(y2.arYatzy()==false){
}
ggr++;
varv = (ggr == 100000);
} while(!varv);
long slutTid = System.currentTimeMillis();
System.out.println("Det blev yatzy "+antal+" gånger"+" Sökning tog :"+(slutTid - startTid) + " ms");
}
}
I want to perform the if /else statment in the main class depending on what arYatzy returns.