Probleme java variable aleatoire

Résolu/Fermé
guess025 Messages postés 3 Date d'inscription mercredi 28 novembre 2012 Statut Membre Dernière intervention 28 novembre 2012 - 28 nov. 2012 à 13:44
guess025 Messages postés 3 Date d'inscription mercredi 28 novembre 2012 Statut Membre Dernière intervention 28 novembre 2012 - 28 nov. 2012 à 14:25
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 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
28 nov. 2012 à 14:16
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 mercredi 28 novembre 2012 Statut Membre Dernière intervention 28 novembre 2012
28 nov. 2012 à 14:25
merci moi qui chercher compliquer
0