dimanche 1 décembre 2019

Is there a way to get the Math.min() for random integers? Java

I am currently making a game and I'm trying to compare the shortest path that is displayed on screen (which is a random generated path of integers) and the path that the user takes. This part of the code is the one in which I try to get the Math.min() of the total paths on screen:

int path1 = randomNum3 + randomNum8;
int path2 = randomNum2 + randomNum7;
int path3 = randomNum + randomNum6;
int path4 = randomNum3 + randomNum5 + randomNum7;
int path5 = randomNum2 + randomNum5 + randomNum8;
int path6 = randomNum + randomNum4 + randomNum7;
int path7 = randomNum2 + randomNum4 + randomNum6;


int caminoMasCorto = Math.min(path1, path2, path3, path4, path5,
        path6, path7);

The error that is showing me is this one:

no suitable method found for min(int,int,int,int,int,int,int)

method Math.min(int,int) is not applicable

(actual and formal argument lists differ in length)




Aucun commentaire:

Enregistrer un commentaire