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

Langage Java Discussion :

Return - valeur impossible


Sujet :

Langage Java

  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut Return - valeur impossible
    Bonsoir !

    je suis entrain de développer un petit applet java et pour la première fois depuis mes débuts, je rencontre un problème qui est vraiment ... bizarre 0o

    j'explique, j'ai une méthode qui renvoi un boolean :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    public boolean isMagnetic( Piece pieceFrom ) {
    		if( blabla ) {
    			if( blabla2 ) { // je ne met pas les 2 conditions ensemble pour une extension future...
                                    // instructions
    				if( blabla3 ) {
    					System.out.println("TRUE");
    					return true;
    				}
    			}
    		}
    		System.out.println("FALSE");
    		return false;
    	}
    et là, j'ai dans le log un "FALSE" mais quand je fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    System.out.println("isMagnetic retourne "+ machin.isMagnetic(this));
    j'obtiens un beau "true" Oo

    Avouez que c'est incompréhensible ?!?

    si vous avez des suggestions je suis preneur...

    merci

  2. #2
    Membre chevronné Avatar de Bezout
    Profil pro
    Développement
    Inscrit en
    Septembre 2003
    Messages
    234
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Cher (Centre)

    Informations professionnelles :
    Activité : Développement

    Informations forums :
    Inscription : Septembre 2003
    Messages : 234
    Par défaut
    C'est d'avoir "true" en minuscules ton probleme ???

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    hihi non ^^

    c'est que dans le log j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    FALSE
    isMagnetic retourne true
    Ce qui est impossible, puisque que si "FALSE" s'affiche, alors "return false;" devrait être appelé, et la méthode retournerait alors false et non pas true !

    Et si on prend le problème dans l'autre sens, si la méthode a retourné true, alors il est impossible que l'instruction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    System.out.println("FALSE");
    soit executée !

  4. #4
    Membre chevronné Avatar de Bezout
    Profil pro
    Développement
    Inscrit en
    Septembre 2003
    Messages
    234
    Détails du profil
    Informations personnelles :
    Âge : 47
    Localisation : France, Cher (Centre)

    Informations professionnelles :
    Activité : Développement

    Informations forums :
    Inscription : Septembre 2003
    Messages : 234
    Par défaut
    ah OK

    Effectivement c'est bizarre.



    Donne plus d'infos peut etre. Source d'origine, logs, ...

  5. #5
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    Merci pour ta réponse

    ben le code source est grand ^^ donc je vais pas pouvoir vous le donner

    je peux essayer d'élargir un peu, mais ça devient plus le bordel ^^, ici la méthode isMagnetic renvoi un int, c'était juste pour voir si ça change quelque chose... mais non c'est toujours faux.

    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
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    public void moveFromMouse( int mouseX, int mouseY ) {
    		double oldX = getX();
    		double oldY = getY();
    		double deltaX;
    		double deltaY;
    
    		setPosition( mouseX, mouseY );
    	
    		boolean magnet = false;
    		if( motor == null ) {
    			ArrayList<Piece> pieceMagnet = new ArrayList<Piece>(1);
    			for( int i = 0; i < Engrenage.getAllPiece().size(); i++ ) {
    				if( Engrenage.getAllPiece().get(i).isMagnetic(this) == 1 )
    				{
    					System.out.println("isMagnetic est = "+ Engrenage.getAllPiece().get(i).isMagnetic(this));
    					pieceMagnet.add( Engrenage.getAllPiece().get(i) );
    				}
    			}
    			
    			if( pieceMagnet.size() > 0 ) {
    				pieceMagnet.get(0).magnetization(this);
    				
    				deltaX = getX() - oldX;
    				deltaY = getY() - oldY;
    				if( linkedAxis.linkedGear.size() == 1 ) {
    					linkedAxis.moveFromGear( deltaX, deltaY, this );
    				}
    				else // This se détache de son axe !
    					linkedAxis.removeLinkedGear(this);
    				for(int j = 0; j < linkedGear.size(); j++) {
    					linkedGear.get(j).moveFromGear( deltaX, deltaY );
    				}
    				magnet = true;
    			}
    		}
    
    		if( !magnet ) {
    			System.out.println("!magnet de "+ this);
    			deltaX = getX() - oldX;
    			deltaY = getY() - oldY;
    			if ( linkedGearUp != null ) {
    				linkedGearUp.removeLinkedGear(this);
    				linkedGearUp = null;
    			}
    			if( linkedAxis.linkedGear.size() == 1 ) {
    				linkedAxis.moveFromGear( deltaX, deltaY, this );
    			}
    			else
    				linkedAxis.removeLinkedGear(this);
    			for(int i = 0; i < linkedGear.size(); i++) {
    				linkedGear.get(i).moveFromGear( deltaX, deltaY );
    			}
    		}
    
    	}
    	
    	public int isMagnetic( Piece pieceFrom ) {
    		System.out.println("isMagnetic de "+ this);
    		if( magnetic ) {
    			if( pieceFrom instanceof Gear ) {
    				Gear gear = (Gear) pieceFrom;
    				boolean ok = true;
    				Gear tempGearUp = this;
    				if( tempGearUp == gear ) // VRAIMENT UTILE ??
    					ok = false;
    				while( tempGearUp.linkedGearUp != null ) {
    					tempGearUp = tempGearUp.linkedGearUp;
    					if( tempGearUp == gear )
    						ok = false;
    				}
    				
    				double delta = Math.sqrt(Math.pow(getX()-gear.getX(), 2) + Math.pow(getY()-gear.getY(), 2)) - pitchC-gear.pitchC;
    				System.out.println("Delta entre "+ this+" et "+gear+" = "+delta);
    				if( ok && delta < 40 && delta > -40 ) {
    					System.out.println("TRUE");
    					return 1;
    				}
    			}
    		}
    		System.out.println("FALSE");
    		return 0;
    	}
    	
    	public void magnetization( Piece pieceFrom ) {
    		System.out.println("magnetization de "+ this+" et de "+ pieceFrom);
    		if( pieceFrom instanceof Gear ) {
    			Gear gear = (Gear) pieceFrom;
    			if( gear.linkedGearUp != null )
    				gear.linkedGearUp.removeLinkedGear(gear);
    			gear.linkedGearUp = this;
    			this.setLinkedGear(gear);
    			double dist = Math.sqrt(Math.pow(getX()-gear.getX(), 2) + Math.pow(getY()-gear.getY(), 2));
    			int x = (int) (getX()+( (gear.getX()-getX()) * (pitchC + gear.pitchC) / dist) );
    			int y = (int) (getY()+( (gear.getY()-getY()) * (pitchC + gear.pitchC) / dist) );
    			gear.setPosition(x, y);
    			gear.meshing();
    		}
    	}
    ,tout cela dans la classe Gear.

    Ce bout de code est là pour déplacer un engrenage avec la souris. Avant tout marchait quand les méthodes isMagnetic() et magnetization() étaient "dans" la méthode moveFromMouse(), mais j'ai du changer ça pour pouvoir être plus souple, et car je vais devoir rajouter plusieurs autres pièces en plus que les engrenages.

  6. #6
    Membre éprouvé
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    132
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mai 2007
    Messages : 132
    Par défaut
    ton problème est étrange donc pour le comprendre j'ai deux questions:
    * Est-ce que ton programe utilise des threads.
    * Est-ce que tu as une exception non catchée ou alors un exception catchée que tu ignores ?

  7. #7
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    Oui il utilise des threads, mais dans ce cas normalement ils ne rentrent pas en ligne de compte.
    Et non je n'ai rien ignoré, rien "catché".

    merci

  8. #8
    Membre éprouvé
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    132
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mai 2007
    Messages : 132
    Par défaut
    Toujours dans l'idée d'avoir un meilleure comprehension du problème, pourrais-tu créer une méthode statique pour afficher tous tes messages?
    Par exemple:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
        static void printConsole (String message){
            synchronized (System.out){
              StringBuilder buffer = new StringBuilder (message.length()+100);
     
              buffer.append(DateFormat.getDateTimeInstance().format(new Date()));
              buffer.append('[');
              buffer.append (Thread.currentThread().getId());
              buffer.append (':');
              buffer.append (Thread.currentThread().getName());
              buffer.append (']');
              buffer.append (message);
              System.out.println (buffer.toString());
            }        
        }
    Ensuite il serait bien que tu nous envoies l'ouput de ton programme pour que l'on puisse un peu mieux comprendre ton problème.
    Ton problème doit avoir une explication logique

  9. #9
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    
    Engrenage.getAllPiece().get(i).isMagnetic(this)
    Que crois-tu que this représente ici ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  10. #10
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    Citation Envoyé par OButterlin Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    
    Engrenage.getAllPiece().get(i).isMagnetic(this)
    Que crois-tu que this représente ici ?
    Ben l'instance de la classe Gear depuis laquelle j'appelle la méthode non ?

    sinon voilà ce que j'obtiens avec la méthode de elmor :
    - on rentre dans la méthode
    - il trouve un delta
    - il écrit false
    - MAIS il renvoit true !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    22 janv. 2008 16:53:32[17:AWT-EventQueue-1]isMagnetic de Gear@89cf1e
    22 janv. 2008 16:53:32[17:AWT-EventQueue-1]Delta entre Gear@89cf1e et Gear@79717e = 175.11800995680346
    22 janv. 2008 16:53:32[17:AWT-EventQueue-1]false
    22 janv. 2008 16:53:32[17:AWT-EventQueue-1]isMagnetic est = 1
    merci pour votre attention

  11. #11
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    encore un nouveau truc que je viens de remarquer...
    Quand le delta est bien entre -40 et 40 (donc que mon engrenage se lie avec un autre), voilà le log :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]isMagnetic de Gear@5a0305
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]Delta entre Gear@5a0305 et Gear@81d2e = -1.3454237113968759
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]true
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]isMagnetic de Gear@5a0305
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]Delta entre Gear@5a0305 et Gear@81d2e = -1.3454237113968759
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]true
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]isMagnetic est = 1
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]isMagnetic est = 1
    Le programme rentre 2 fois dans la méthode et le renvoi est écrit à chaque fois à la fin... encore un mystère

    bon j'espère que vous y verrez plus clair, car moi je suis perdu..

  12. #12
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    C'est curieux comme problème...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    if( Engrenage.getAllPiece().get(i).isMagnetic(this) == 1 )
    {
        System.out.println("isMagnetic est = "+ Engrenage.getAllPiece().get(i).isMagnetic(this));
        pieceMagnet.add( Engrenage.getAllPiece().get(i) );
    }
    pourrais-tu rajouter dans la méthode isMagnetic(...) un System.out.println(magnetic) (on dirait que la valeur change entre les 2 appels)

    Serait-il possible d'avoir le code complet de la classe ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  13. #13
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    magnetic vaut toujours true

    et pour ce que j'ai dis avant, c'est normal car j'appelle 2 fois la méthode ...
    par contre la ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    22 janv. 2008 17:06:56[17:AWT-EventQueue-1]isMagnetic est = 1
    devrait apparaître qu'une fois puisque je fais qu'une fois un println Oo

    OButterlin, je pense pas que tout le code servira, il y a 7 classes avec pas mal de lignes... ce que j'ai mis devrait suffire... mais comme c'est toujours aussi bizarre voici uniquement la classe Gear (pas retravaillée pour vous, donc en chantier...) .
    les commentaires dans la méthode moveFromGear() sont l'ancienne implémentation, et ça marchait, mais j'ai besoin de séparer maintenant...
    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
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.Toolkit;
    import java.awt.geom.AffineTransform;
    import java.awt.geom.GeneralPath;
    import java.awt.geom.PathIterator;
    import java.text.DateFormat;
    import java.util.ArrayList;
    import java.util.Date;
     
     
    public class Gear extends Piece {
     
    	private Axis linkedAxis;
    	//private ArrayList<Gear> linkedGear = new ArrayList<Gear>(1);
    	public Gear linkedGearUp = null;
     
    	private static final double module = 5;
    	public int N; // Number of teeth
    	public double rootC; // Root circle
    	public double pitchC; // Pitch circle
    	public double outsideC; // Outside circle
    	private double alpha;
    	private double angleMeshing = 0;
    	private double angleRotation = 0;
    	private double angle = angleMeshing + angleRotation;
    	private Motor motor = null;
     
    	private GeneralPath path = new GeneralPath();
    	private GeneralPath pathRotate;
    	private GeneralPath pathTeeth = new GeneralPath();
    	private AffineTransform at = new AffineTransform();
     
    	public Gear( double x, double y, int initN ) {
    		setPosition(x, y);
    		setN( initN );
    		pitchC = N * module;
    		outsideC = (N+2) * module;
    		rootC = pitchC - 2.5 * module;
     
    		alpha = 2 * Math.PI /N;
     
    		magnetic = true;
     
    		linkedAxis = new Axis( getX(), getY() );
    		linkedAxis.setLinkedGear(this);
     
    		findDepth();
     
    		Engrenage.addPiece( this );
    		Engrenage.addPiece( linkedAxis );
    		Engrenage.sortPiece();
    		createPath();
    	}
     
    	public void draw( Graphics2D g2d ) {
    		/*
    		g2d.setColor( new Color(240, 240, 240) );
    		g2d.fillOval((int) position.getX() - rootC,(int)  position.getY() - rootC,
    				rootC*2, rootC*2);
    		g2d.setColor( Color.black );
    		g2d.drawOval((int) position.getX() - rootC,(int)  position.getY() - rootC,
    				rootC*2, rootC*2);
    		g2d.drawOval((int) position.getX() - pitchC,(int)  position.getY() - pitchC,
    				pitchC*2, pitchC*2);
    		g2d.drawOval((int) position.getX() - outsideC,(int)  position.getY() - outsideC,
    				outsideC*2, outsideC*2);
    				*/
    		g2d.setStroke( stroke );
     
    		if( motor != null)
    			g2d.setColor( new Color(230, 250, 230) ); // MOTEUR
    		else if( linkedGearUp == null )
    			g2d.setColor( new Color(250, 230, 230) ); // MOTEUR POTENTIEL
    		else 
    			g2d.setColor( new Color(230, 230, 250) ); // NORMAL
    		g2d.fill( translate((int)getX(), (int)getY()) );
    		g2d.setColor( Color.black );
    		g2d.draw( translate((int)getX(), (int)getY()) );
    		g2d.drawLine((int)getX(), (int)getY(), (int)(20*Math.cos(angle)+getX()), 
    				(int)(20*Math.sin(angle)+getY()));
     
    		/*
    		for( int i = 0; i < this.linkedGear.size(); i++ ) {
    			g2d.drawLine((int)getX(), (int)getY(), (int)linkedGear.get(i).getX(), (int)linkedGear.get(i).getY());
    		}
    		*/
     
    	}
     
     
    	public GeneralPath translate( int tx, int ty ) {
    		GeneralPath newPath = new GeneralPath();
    		at.setToTranslation(tx, ty);
    		PathIterator pi = pathRotate.getPathIterator( at );
    		newPath.append(pi, false);
    		return newPath;
    	}
     
    	public void moveFromAxis( double deltaX, double deltaY ) {
     
    		setPosition( getX() + deltaX, getY() + deltaY );
    		if( linkedGearUp != null ) {
    			linkedGearUp.removeLinkedGear( this );
    			linkedGearUp = null;
    		}
     
    		for(int i = 0; i < linkedGear.size(); i++) {
    			linkedGear.get(i).moveFromGear( deltaX, deltaY );
    		}
    	}
     
    	public void moveFromGear( double deltaX, double deltaY ) {
     
    		setPosition( getX() + deltaX, getY() + deltaY );
     
    		meshing(); // Comment enlever ça ?????????????????????
     
    		linkedAxis.moveFromGear( deltaX, deltaY, this );
     
    		for(int i = 0; i < linkedGear.size(); i++) {
    			linkedGear.get(i).moveFromGear( deltaX, deltaY );
    		}
    	}
     
    	public void moveFromMouse( int mouseX, int mouseY ) {
    		double oldX = getX();
    		double oldY = getY();
    		double deltaX;
    		double deltaY;
     
    		setPosition( mouseX, mouseY );
     
    		boolean magnet = false; // Si oui ou non on a trouvé un gear à quoi se lier
    		if( motor == null ) {
    			ArrayList<Piece> pieceMagnet = new ArrayList<Piece>(1);
    			for( int i = 0; i < Engrenage.getAllPiece().size(); i++ ) {
    				if( Engrenage.getAllPiece().get(i).isMagnetic(this) == 1 )
    				{
    					printConsole("isMagnetic est = "+ Engrenage.getAllPiece().get(i).isMagnetic(this));
    					pieceMagnet.add( Engrenage.getAllPiece().get(i) );
     
    					/*
    					Gear gear = Engrenage.getAllPiece().get(i);
    					boolean ok = true;
    					Gear tempGearUp = gear;
    					if( tempGearUp == this ) // VRAIMENT UTILE ??
    						ok = false;
    					while( tempGearUp.linkedGearUp != null ) {
    						tempGearUp = tempGearUp.linkedGearUp;
    						if( tempGearUp == this )
    							ok = false;
    					}
    					if( ok ) {
    						double delta = Math.sqrt(Math.pow(gear.getX()-mouseX, 2) + Math.pow(gear.getY()-mouseY, 2)) - gear.pitchC-pitchC;
     
    						if( delta < 40 && delta > -40 ) {
    							gearNear.add( gear );
    						}
    					}
    					*/
    				}
    			}
     
    			if( pieceMagnet.size() > 0 ) {
    				pieceMagnet.get(0).magnetization(this);
     
    				deltaX = getX() - oldX;
    				deltaY = getY() - oldY;
    				if( linkedAxis.linkedGear.size() == 1 ) {
    					linkedAxis.moveFromGear( deltaX, deltaY, this );
    				}
    				else // This se détache de son axe !
    					linkedAxis.removeLinkedGear(this);
    				for(int j = 0; j < linkedGear.size(); j++) {
    					linkedGear.get(j).moveFromGear( deltaX, deltaY );
    				}
    				magnet = true;
    			}
     
    			/*
    			if( gearNear.size() > 0 ) {
    				Gear gear = gearNear.get(0);
    				if( linkedGearUp != null )
    					linkedGearUp.removeLinkedGear(this);
    				linkedGearUp = gear;
    				gear.setLinkedGear(this);
    				double dist = Math.sqrt(Math.pow(gear.getX()-getX(), 2) + Math.pow(gear.getY()-getY(), 2));
    				int x = (int) (gear.getX()+( (getX()-gear.getX()) * (gear.pitchC + pitchC) / dist) );
    				int y = (int) (gear.getY()+( (getY()-gear.getY()) * (gear.pitchC + pitchC) / dist) );
    				setPosition(x, y);
    				meshing();
    				deltaX = getX() - oldX;
    				deltaY = getY() - oldY;
    				if( linkedAxis.linkedGear.size() == 1 ) {
    					linkedAxis.moveFromGear( deltaX, deltaY, this );
    				}
    				else // This se détache de son axe !
    					linkedAxis.removeLinkedGear(this);
    				for(int j = 0; j < linkedGear.size(); j++) {
    					linkedGear.get(j).moveFromGear( deltaX, deltaY );
    				}
    				magnet = true;
    			}
    			*/
    		}
     
    		if( !magnet ) {
    			System.out.println("!magnet de "+ this);
    			deltaX = getX() - oldX;
    			deltaY = getY() - oldY;
    			if ( linkedGearUp != null ) {
    				linkedGearUp.removeLinkedGear(this);
    				linkedGearUp = null;
    			}
    			if( linkedAxis.linkedGear.size() == 1 ) {
    				linkedAxis.moveFromGear( deltaX, deltaY, this );
    			}
    			else // This se détache de son axe !
    				linkedAxis.removeLinkedGear(this);
    			for(int i = 0; i < linkedGear.size(); i++) {
    				linkedGear.get(i).moveFromGear( deltaX, deltaY );
    			}
    		}
     
    	}
     
    	public int isMagnetic( Piece pieceFrom ) {
    		printConsole("isMagnetic de "+ this);
    		printConsole( "magnetic = " + magnetic );
    		if( magnetic ) {
    			if( pieceFrom instanceof Gear ) {
    				Gear gear = (Gear) pieceFrom;
    				boolean ok = true;
    				Gear tempGearUp = this;
    				if( tempGearUp == gear ) // VRAIMENT UTILE ??
    					ok = false;
    				while( tempGearUp.linkedGearUp != null ) {
    					tempGearUp = tempGearUp.linkedGearUp;
    					if( tempGearUp == gear )
    						ok = false;
    				}
     
    				double delta = Math.sqrt(Math.pow(getX()-gear.getX(), 2) + Math.pow(getY()-gear.getY(), 2)) - pitchC-gear.pitchC;
    				printConsole("Delta entre "+ this+" et "+gear+" = "+delta);
    				if( ok && delta < 40 && delta > -40 ) {
    					printConsole("true");
    					return 1;
    				}
    			}
    		}
    		printConsole("false");
    		return 0;
    	}
     
    	public void magnetization( Piece pieceFrom ) {
    		System.out.println("magnetization de "+ this+" et de "+ pieceFrom);
    		if( pieceFrom instanceof Gear ) {
    			Gear gear = (Gear) pieceFrom;
    			if( gear.linkedGearUp != null )
    				gear.linkedGearUp.removeLinkedGear(gear);
    			gear.linkedGearUp = this;
    			this.setLinkedGear(gear);
    			double dist = Math.sqrt(Math.pow(getX()-gear.getX(), 2) + Math.pow(getY()-gear.getY(), 2));
    			int x = (int) (getX()+( (gear.getX()-getX()) * (pitchC + gear.pitchC) / dist) );
    			int y = (int) (getY()+( (gear.getY()-getY()) * (pitchC + gear.pitchC) / dist) );
    			gear.setPosition(x, y);
    			gear.meshing();
    		}
    	}
     
    	static void printConsole (String message){
    		synchronized (System.out){
    			StringBuilder buffer = new StringBuilder (message.length()+100);
     
    			buffer.append(DateFormat.getDateTimeInstance().format(new Date()));
    			buffer.append('[');
    			buffer.append (Thread.currentThread().getId());
    			buffer.append (':');
    			buffer.append (Thread.currentThread().getName());
    			buffer.append (']');
    			buffer.append (message);
    			System.out.println (buffer.toString());
    		}        
    	}
     
    	public void rotateMeshing( double a ) {
     
    		angleMeshing = a;
     
    		rotate();
     
    		for(int i = 0; i < linkedGear.size(); i++) {
    			linkedGear.get(i).meshing();
    		}
    	}
     
    	public void rotateMotor( double a ) {
     
    		angleRotation += a;
     
    		if( angleRotation > Math.PI*2 )
    			angleRotation -=  Math.PI*2;
    		else if( angleRotation < 0 )
    			angleRotation +=  Math.PI*2;
     
    		rotate();
     
    		for(int i = 0; i < linkedGear.size(); i++) {
     
    			//linkedGear.get(i).meshing();
    			linkedGear.get(i).rotateMotor( ((double)N / (double)linkedGear.get(i).N) * -a );
    		}
    	}
     
    	public void rotate() {
    		angle = angleMeshing + angleRotation;
    		if( angle > Math.PI*2 )
    			angle -=  Math.PI*2;
    		else if( angle < 0 )
    			angle +=  Math.PI*2;
     
    		pathRotate = new GeneralPath(path);
    		at.setToRotation( angle );
    		pathRotate.transform( at );
    	}
     
    	/*
    	public void rotate( double a ) {
    		pathRotate = new GeneralPath(path);
    		at.setToRotation( a );
    		pathRotate.transform( at );
    		angle = a;
     
    		for(int i = 0; i < linkedGear.size(); i++) {
    			linkedGear.get(i).rotate(this);
    		}
    	}
    	*/
     
     
    	/*
    	public void rotateAgain( double a ) {
    		pathRotate = new GeneralPath(pathRotate);
    		at.setToRotation( a );
    		pathRotate.transform( at );
    		angle += a;
     
    		if( angle > Math.PI*2 )
    			angle -=  Math.PI*2;
     
    		for(int i = 0; i < linkedGear.size(); i++) {
    			linkedGear.get(i).rotate(this);
    		}
    	}
    	*/
     
    	public void meshing() {
     
    		double angleGearUp = 0; // angle de la roue spérieur en radian
    		double angleThis = 0; // angle de cette roue  en radian
    		if( getX() > linkedGearUp.getX() ) {
    			if( getY() >= linkedGearUp.getY() ) { // CAS 1 : en bas à droite
    				double sup = getY()-linkedGearUp.getY();
    				double inf = getX()-linkedGearUp.getX();
    				double a = Math.atan( sup / inf );
    				angleGearUp = 2 * Math.PI - a;
    			}
    			if( getY() < linkedGearUp.getY() ) { // CAS 2 : en haut à droite
    				double sup = linkedGearUp.getY()-getY();
    				double inf = getX()-linkedGearUp.getX();
    				angleGearUp = Math.atan( sup / inf );
    			}
    		}
    		if( getX() < linkedGearUp.getX() ) { 
    			if( getY() >= linkedGearUp.getY() ) { // CAS 3 : en bas à gauche
    				double sup = getY()-linkedGearUp.getY();
    				double inf = linkedGearUp.getX()-getX();
    				double a = Math.atan( sup / inf );
    				angleGearUp = Math.PI + a;
    			}
    			if( getY() < linkedGearUp.getY() ) { // CAS 4 : en haut à gauche
    				double sup = linkedGearUp.getY()-getY();
    				double inf = linkedGearUp.getX()-getX();
    				double a = Math.atan( sup / inf );
    				angleGearUp = Math.PI - a;
    			}
    		}
    		else if( getX() == linkedGearUp.getX() ) {
    			if( getY() >= linkedGearUp.getY() ) { // CAS 5 : en bas
    				angleGearUp = 3/2 * Math.PI;
    			}
    			if( getY() < linkedGearUp.getY() ) { // CAS 6 : en haut
    				angleGearUp = Math.PI / 2;
    			}
    		}
    		angleGearUp += linkedGearUp.angle;
    		double howManyGearUp = angleGearUp / ( 2*Math.PI / linkedGearUp.N );
    		double afterDotGearUp = howManyGearUp - (int) howManyGearUp;
    		double deltaAngleGearUp = afterDotGearUp * ( 2*Math.PI / linkedGearUp.N );
     
    		if( linkedGearUp.getX() > getX() ) {
    			if( linkedGearUp.getY() >= getY() ) { // CAS 1 : en bas à droite
    				double sup = linkedGearUp.getY()-getY();
    				double inf = linkedGearUp.getX()-getX();
    				double a = Math.atan( sup / inf );
    				angleThis = 2 * Math.PI - a;
    			}
    			if( linkedGearUp.getY() < getY() ) { // CAS 2 : en haut à droite
    				double sup = getY()-linkedGearUp.getY();
    				double inf = linkedGearUp.getX()-getX();
    				angleThis = Math.atan( sup / inf );
    			}
    		}
    		if( linkedGearUp.getX() < getX() ) { 
    			if( linkedGearUp.getY() >= getY() ) { // CAS 3 : en bas à gauche
    				double sup = linkedGearUp.getY()-getY();
    				double inf = getX()-linkedGearUp.getX();
    				double a = Math.atan( sup / inf );
    				angleThis = Math.PI + a;
    			}
    			if( linkedGearUp.getY() < getY() ) { // CAS 4 : en haut à gauche
    				double sup = getY()-linkedGearUp.getY();
    				double inf = getX()-linkedGearUp.getX();
    				double a = Math.atan( sup / inf );
    				angleThis = Math.PI - a;
    			}
    		}
    		else if( linkedGearUp.getX() == getX() ) {
    			if( linkedGearUp.getY() >= getY() ) { // CAS 5 : en bas
    				angleThis = Math.PI / 2;
    			}
    			if( linkedGearUp.getY() < getY() ) { // CAS 6 : en haut
    				angleThis = 3/2 * Math.PI;
    			}
    		}
    		angleThis += angleRotation;
     
    		rotateMeshing( 2*Math.PI - (angleThis - Math.PI/N + ( deltaAngleGearUp/N*linkedGearUp.N ) ) );
    		/*
    		System.out.println("angleGearUp : "+Math.toDegrees(angleGearUp)+
    				"\nangleThis : "+Math.toDegrees(angleThis)+
    				"\nhowManyGearUp : "+howManyGearUp);
    		*/
    	}
     
    	public void delete() {
    		if( linkedGearUp != null)
    			linkedGearUp.removeLinkedGear( this );
    		for( int i = 0; i < getLinkedGear().size(); i++ ) {
    			getLinkedGear().get(i).linkedGearUp = null;
    		}
    		if( motor != null ) {
    			motor.finish();
    		}
     
    		if( linkedAxis.linkedGear.size() == 1 ) {
    			Engrenage.removePiece( linkedAxis );
    			System.out.println( linkedAxis + " deleted" );
    		}
     
    		Engrenage.removePiece( this );
        	System.out.println( this + " deleted" );
    	}
     
    	public void setN( int newN ) {
    		if( newN > 6 )
    			N = newN;
    		else
    			Toolkit.getDefaultToolkit().beep();
    	}
     
    	public void setDepth( int newDepth ) {
    		this.depth = newDepth;
    		System.out.println( "newDepth :" + newDepth);
    		this.linkedAxis.setDepth( newDepth + 1 );
    	}
     
    	public void setLinkedGear( Gear gear ) {
    		linkedGear.add( gear );
    	}
     
    	public void removeLinkedGear( Gear gear ) {
    		linkedGear.remove( gear );
    	}
     
    	public void setMotor( Motor m) {
    		motor = m;
    	}
     
    	public Motor getMotor() {
    		return motor;
    	}
     
    	public Axis getAxis() {
    		return linkedAxis;
    	}
     
    	public ArrayList<Gear> getLinkedGear() {
    		return linkedGear;
    	}
     
    	public boolean contains( int x, int y ) {
    		return translate((int)getX(), (int)getY()).contains(x, y);
    	}
     
    	private void findDepth() {
    		ArrayList<Gear> allGear = new ArrayList<Gear>(1);
     
    		for( int i = 0; i < Engrenage.getAllPiece().size(); i++ ) {
    			if( Engrenage.getAllPiece().get(i) instanceof Gear ) {
    				allGear.add( (Gear) Engrenage.getAllPiece().get(i) );
    			}
    		}
     
    		System.out.println( "*********  " + allGear.size() );
     
    		sortByInsertion( allGear, 0, allGear.size()-1 );
     
    		System.out.println( "Après tri : " );
    		for( int i = allGear.size()-1; i >= 0; i--) {
    			System.out.println( "N " + i + " = " + allGear.get(i).N );
    		}
     
    		boolean limitPassed = false;
    		for( int i = allGear.size()-1; i >= 0; i--) {
    			System.out.println( "Dans la boucle et i = " + i );
    			if( limitPassed )
    				allGear.get(i).setDepth( allGear.get(i+1).linkedAxis.getDepth() + 1 );
    			if( N > allGear.get(i).N && !limitPassed) {
    				if( i == allGear.size()-1 ) { // Si plus grande que toutes
    					System.out.println( "Cas 1 et i = " + i );
    					setDepth( 0 );
    					allGear.get(i).setDepth( this.linkedAxis.getDepth() + 1 );
    					limitPassed = true;
    				}
    				else {
    					System.out.println( "Cas Normal et i = " + i );
    					setDepth( allGear.get(i+1).linkedAxis.getDepth() + 1 );
    					allGear.get(i).setDepth( this.linkedAxis.getDepth() + 1 );
    					limitPassed = true;
    				}
    			}
    			else if( i == 0 && !limitPassed ) { // Si plus petite que toutes
    				System.out.println( "Cas 2 et i = " + i );
    				setDepth( allGear.get(i).linkedAxis.getDepth() + 1 );
    			}
     
    		}
    		if( allGear.size() == 0 ) {
    			this.setDepth( 0 );
    			System.out.println( "allGear vide" );
    		}
     
    	}
     
    	private boolean less( int v, int w ) {
    		return v < w;
    	}
     
    	private void exch( ArrayList<Gear> a, int i, int j ) {
    		Gear t = a.get(i);
    		a.set( i, a.get(j) );
    		a.set( j, t );
    	}
     
    	private void compExch( ArrayList<Gear> a, int i, int j ) {
    		if( less(a.get(j).N, a.get(i).N) )
    			exch( a, i, j );
    	}
     
    	private void sortByInsertion( ArrayList<Gear> a, int l, int r ) {
    		int i;
    		for(i = r; i > l; i--)
    			compExch( a, i-1, i);
    		for(i = l+2; i <= r; i++) {
    			int j = i;
    			Gear v = a.get(i);
    			while( less(v.N, a.get(j-1).N) ) {
    				a.set( j, a.get(j-1) );
    				j--;
    			}
    			a.set( j, v );
    		}
    	}
     
    	private void createPathTeeth() {
     
    		float x = (float) (rootC * Math.cos(-alpha/2));
    		float y = (float) (rootC * Math.sin(-alpha/2));
    		pathTeeth.moveTo(x, y);
    		x = (float) (rootC * Math.cos(-alpha/4));
    		y = (float) (rootC * Math.sin(-alpha/4));
    		pathTeeth.lineTo(x, y);
     
    		x = (float) ((pitchC - 1.25*module/1.5) * Math.cos(-alpha/4));
    		y = (float) ((pitchC - 1.25*module/1.5) * Math.sin(-alpha/4));
    		pathTeeth.lineTo(x, y);
     
    		float x1 = (float) (pitchC * Math.cos(-alpha/4));
    		float y1 = (float) (pitchC * Math.sin(-alpha/4));
    		float x2 = (float) (outsideC * Math.cos(-alpha/9));
    		float y2 = (float) (outsideC * Math.sin(-alpha/9));
    		pathTeeth.quadTo(x1, y1, x2, y2);
     
    		x = (float) (outsideC * Math.cos(alpha/9));
    		y = (float) (outsideC * Math.sin(alpha/9));
    		pathTeeth.lineTo(x, y);
     
    		x1 = (float) (pitchC * Math.cos(alpha/4));
    		y1 = (float) (pitchC * Math.sin(alpha/4));
    		x2 = (float) ((pitchC - 1.25*module/1.5) * Math.cos(alpha/4));
    		y2 = (float) ((pitchC - 1.25*module/1.5) * Math.sin(alpha/4));
    		pathTeeth.quadTo(x1, y1, x2, y2);
     
    		x = (float) (rootC * Math.cos(alpha/4));
    		y = (float) (rootC * Math.sin(alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (rootC * Math.cos(alpha/2));
    		y = (float) (rootC * Math.sin(alpha/2));
    		pathTeeth.lineTo(x, y);
     
     
    		/*
    		float x = (float) (rootC * Math.cos(-alpha/2));
    		float y = (float) (rootC * Math.sin(-alpha/2));
    		pathTeeth.moveTo(x, y);
    		x = (float) (rootC * Math.cos(-alpha/4));
    		y = (float) (rootC * Math.sin(-alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (pitchC * Math.cos(-alpha/4));
    		y = (float) (pitchC * Math.sin(-alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (outsideC * Math.cos(-alpha/8));
    		y = (float) (outsideC * Math.sin(-alpha/8));
    		pathTeeth.lineTo(x, y);
    		x = (float) (outsideC * Math.cos(alpha/8));
    		y = (float) (outsideC * Math.sin(alpha/8));
    		pathTeeth.lineTo(x, y);
    		x = (float) (pitchC * Math.cos(alpha/4));
    		y = (float) (pitchC * Math.sin(alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (rootC * Math.cos(alpha/4));
    		y = (float) (rootC * Math.sin(alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (rootC * Math.cos(alpha/2));
    		y = (float) (rootC * Math.sin(alpha/2));
    		pathTeeth.lineTo(x, y);
    		*/
    		/*
    		float x = (float) (rootC * Math.cos(-alpha/2));
    		float y = (float) (rootC * Math.sin(-alpha/2));
    		pathTeeth.moveTo(x, y);
    		x = (float) (rootC * Math.cos(-alpha/4));
    		y = (float) (rootC * Math.sin(-alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (outsideC * Math.cos(-alpha/8));
    		y = (float) (outsideC * Math.sin(-alpha/8));
    		pathTeeth.lineTo(x, y);
    		x = (float) (outsideC * Math.cos(alpha/8));
    		y = (float) (outsideC * Math.sin(alpha/8));
    		pathTeeth.lineTo(x, y);
    		x = (float) (rootC * Math.cos(alpha/4));
    		y = (float) (rootC * Math.sin(alpha/4));
    		pathTeeth.lineTo(x, y);
    		x = (float) (rootC * Math.cos(alpha/2));
    		y = (float) (rootC * Math.sin(alpha/2));
    		pathTeeth.lineTo(x, y);
    		*/
    	}
     
    	private void createPath() {
    		createPathTeeth();
    		path.append(pathTeeth, false);
    		for( int i = 1; i < N; i++ ) {
    			path.append( rotateTeeth( i* alpha ), true);
    		}
    		path.closePath();
    		pathRotate =  new GeneralPath(path);
    	}
     
    	private GeneralPath rotateTeeth( double angle ) {
    		GeneralPath newTeeth = new GeneralPath();
    		at.setToRotation( angle );
    		PathIterator pi = pathTeeth.getPathIterator( at );
    		newTeeth.append(pi, false);
    		return newTeeth;
    	}
    }
    EDIT :
    la réflexion sur mon précédent message vient de me faire remarquer que justement la méthode est appellée 2 fois (si elle renvoie bien 1) : une fois pour la condition if et l'autre pour le println()... mais je ne l'ai qu'une fois dans mon log... et alors cette fois devrait être celle de la condition, et donc on ne devrait jamais avoir le retour du println() !
    Bref je ne comprend rien !

  14. #14
    Membre actif
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Novembre 2006
    Messages : 25
    Par défaut
    Dans des cas de 'mystère' comme celui-ci, utilise un débugger. C'est le moyen le plus rapide de savoir ce qui se passe dans un programme un tant soit peu complexe...

    Bonne chance!

  15. #15
    Membre éprouvé
    Profil pro
    Inscrit en
    Mai 2007
    Messages
    132
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Mai 2007
    Messages : 132
    Par défaut
    un truc que je viens de remarquer est que dans le code on voit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    printConsole( "magnetic = " + magnetic );
    Mais cette ligne n'apparait jamais dans le log ?

  16. #16
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2007
    Messages
    20
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Suisse

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2007
    Messages : 20
    Par défaut
    Si si, j'ai juste rajouté cette ligne après vous avoir donné les logs. tout est normal avec ce qu'elle renvoie.

    Sinon pour mon problème, je vais pour l'instant remettre tout comme avant et faire avec des "instanceof"

    Je vais garder une version actuelle pour chercher le problème quand j'ai le temps ^^ mais ces jours j'ai rien trouvé... faudrait que je reproduise l'erreur dans une classe test ou que j'utilise un débuggeur (ce que je n'ai encore jamais fait, en tout cas pas avec des fonctions avancées).

    Si vous avez une lumineuse idée, je prend... sinon je vais continuer mon bonhomme de chemin pour avancer dans la réalisation du programme.

    merci à vous

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

Discussions similaires

  1. [SQL2005EXP] La fonction AVG me renvoit des valeurs impossibles
    Par gbouchat dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 09/02/2010, 19h44
  2. Modification valeur impossible class template
    Par Nykoo dans le forum Langage
    Réponses: 9
    Dernier message: 11/01/2008, 16h17
  3. Réponses: 2
    Dernier message: 18/12/2006, 00h37
  4. Lecture valeurs CSS impossible :s
    Par balti dans le forum Général JavaScript
    Réponses: 1
    Dernier message: 02/09/2005, 21h32
  5. impossible de changer la valeur d'un hidden...
    Par Palmic dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 31/05/2005, 12h06

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