IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

avec Java Discussion :

Problème de limite de conditions


Sujet :

avec Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de Pecose
    Homme Profil pro
    Batiment
    Inscrit en
    Février 2013
    Messages
    311
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Batiment
    Secteur : Bâtiment

    Informations forums :
    Inscription : Février 2013
    Messages : 311
    Par défaut Problème de limite de conditions
    Bonjour,

    J'aimerai savoir comment gérer le cas ou l'on se retrouve avec plus de dix conditions différentes à traiter. Le switch le if et le else if ont l'air de limité les conditions a dix dans la même méthode. Au delà ca plante.

    Alors y a t'il quelque chose que je ne sais pas, ou l'erreur viens de moi et dans ce cas je vous envoie le code?

    Merci pour toutes aides.

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 277
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 277
    Par défaut
    Poste ton code, car il ne devrait pas y avoir de telle limitation.

  3. #3
    Membre éprouvé Avatar de Sakukun
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2011
    Messages
    74
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Janvier 2011
    Messages : 74
    Par défaut
    Bonjour,

    un code qui fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    ...
    if ( condition1 && contition2 .... && condition15)
    ...
    C'est quand même rare.
    Pose ton code ou ton besoin car je pense que c'est un pb d'algo

  4. #4
    Membre éclairé Avatar de Pecose
    Homme Profil pro
    Batiment
    Inscrit en
    Février 2013
    Messages
    311
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Batiment
    Secteur : Bâtiment

    Informations forums :
    Inscription : Février 2013
    Messages : 311
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    public void ZombieUpdate(float i){
     
    		if(i==1){mapOptionX = -2000; mapOptionY = -2000;}
    		if(i==2){mapOptionX = -1000; mapOptionY = -2000;}
    		if(i==3){mapOptionX = 0; mapOptionY = -2000;}
    		if(i==4){mapOptionX = 1000; mapOptionY = -2000;}
    		if(i==5){mapOptionX = 2000; mapOptionY = -2000;}
    		if(i==6){mapOptionX = -2000; mapOptionY = -1000;}
    		if(i==7){mapOptionX = 2000; mapOptionY = -1000;}
    		if(i==8){mapOptionX = -2000; mapOptionY = 0;}
    		if(i==9){mapOptionX = 2000; mapOptionY = 0;}
    		if(i==10){mapOptionX = -2000; mapOptionY = 1000;}
    		if(i==11){mapOptionX = 2000; mapOptionY = 1000;}
    		if(i==12){mapOptionX = -2000; mapOptionY = 2000;}
    		if(i==13){mapOptionX = -1000; mapOptionY = 2000;}
    		if(i==14){mapOptionX = 0; mapOptionY = 2000;}
    		if(i==15){mapOptionX = 1000; mapOptionY = 2000;}
    		if(i==16){mapOptionX = 2000; mapOptionY = 2000;}
    }
    Dans ma main j'ai a peut de choses pres ca:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    for(int zombieSquare = 1; zombieSquare <= 16; zombieSquare++){
    zombie.ZombieUpdate(zombieSquare);
    }
    En gros il y a l'idée

    Là au dessus de zombieSquare = 9 ca marche plus.
    ni avec ca, ni avec else, ni avec switch.

  5. #5
    Membre éclairé
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    442
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2011
    Messages : 442
    Par défaut
    Ca marche plus avec quel message d'erreur ?

  6. #6
    Membre éclairé Avatar de Pecose
    Homme Profil pro
    Batiment
    Inscrit en
    Février 2013
    Messages
    311
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Batiment
    Secteur : Bâtiment

    Informations forums :
    Inscription : Février 2013
    Messages : 311
    Par défaut
    Thu Dec 19 17:25:23 CET 2013 ERROR:10
    java.lang.ArrayIndexOutOfBoundsException: 10
    at LGP.Game.render(Game.java:142)
    at org.newdawn.slick.state.StateBasedGame.render(StateBasedGame.java:207)
    at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:703)
    at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361)
    at LGP.Main.main(Main.java:34)
    Thu Dec 19 17:25:23 CET 2013 ERROR:Game.render() failure - check the game code.
    org.newdawn.slick.SlickException: Game.render() failure - check the game code.
    at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:706)
    at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:456)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:361)
    at LGP.Main.main(Main.java:34)
    AL lib: (WW) FreeDevice: (0x7f9e2107ea00) Deleting 15 Buffer(s)

  7. #7
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 483
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 483
    Par défaut
    1) on compare jamais un float et un int!! c'est chercher les emmerde.
    2) ton erreur n'a rien à voir avec le code posté. L'erreur se trouve en LGP.Game.render(Game.java:142)
    où tu essaie d'accéder à l'index 10 d'un tableau qui n'a que 10 éléments (donc de 0 à 9 pour ses indexs)

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [MySQL] problème avec LIMIT
    Par gtraxx dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 10/10/2006, 15h58
  2. [Système] Problème de syntaxe dans condition
    Par pierrot10 dans le forum Langage
    Réponses: 10
    Dernier message: 09/10/2006, 15h10
  3. Problème requête avec 2 conditions
    Par omgirl dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 12/07/2006, 17h19
  4. problème de limit
    Par isa21493 dans le forum Requêtes
    Réponses: 6
    Dernier message: 10/03/2006, 14h09
  5. [MFC] Problème de limitation d'un CListCtrl
    Par exal66 dans le forum MFC
    Réponses: 1
    Dernier message: 30/12/2005, 18h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo