Probleme java variable aleatoire

Résolu
guess025 Messages postés 3 Date d'inscription   Statut Membre Dernière intervention   -  
guess025 Messages postés 3 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour, voila mon code le problème est pour la variable aléatoire

public class personnage {
public static void main (String [ ] args) {
int Cpers, Lpers, Lobjectif, Cobjectif ;
int N=5 ;
do {
Ecran.afficherln ( " coordonnée L du personnage" ) ;
Lpers=Clavier.saisirInt () ;
Ecran.afficherln ( " coordonnée C du personnage " ) ;
Cpers=Clavier.saisirInt () ;
if (Lpers>5 || Cpers>5) {
Ecran.afficherln ( " erreur coordonnée impossible veuillez saisir a nouveau " ) ;
}
}while (Lpers>5 || Cpers>5) ;

Ecran.afficherln ( "coordonnée du personnage ( " ,Lpers , ", " , Cpers , " ) " ) ;
do {
Lobjectif= (int) ((math.random() *N) + 1 ) ;
Cobjectif= (int) ((math.random() *N) + 1 ) ;
}while ( Lobjectif==Lpers && Cobjectif==Cpers ) ;

ET VOICI L ERREUR AFFICHER

personnage.java:18: error: cannot find symbol
Lobjectif= (int) ((math.random() *N) + 1 ) ;
^
symbol: variable math
location: class personnage
personnage.java:19: error: cannot find symbol
Cobjectif= (int) ((math.random() *N) + 1 ) ;
^
symbol: variable math
location: class personnage

MERCI D AVANCE POUR VOTRE AIDE
A voir également:

1 réponse

KX Messages postés 16761 Date d'inscription   Statut Modérateur Dernière intervention   3 020
 
Math est une classe, et s'écrit avec un M majuscule :

Lobjectif = (int) ((Math.random() *N) + 1);
Cobjectif = (int) ((Math.random() *N) + 1);
2
guess025 Messages postés 3 Date d'inscription   Statut Membre Dernière intervention  
 
merci moi qui chercher compliquer
0