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 compilation


Sujet :

avec Java

  1. #1
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2011
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2011
    Messages : 45
    Par défaut Problème de compilation
    Bonjour,

    Voici mon programme,

    Code java : 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
    import java.util.*;
     
    public class Spot
    {
    	private String marque;
    	private Led[]tabLed;
    	private Timer timer;
    	private final int tension = 220;
    	private final int minLed = 3;
    	private final int maxLed = 20;
     
    	public String getMarque()
    	{
    		return this.marque;
    	}
     
    	public Timer getTimer()
    	{
    		return this.timer;
    	}
     
    	public Spot(String marque, Led[]l, Timer timer)
    	{
    		this.marque = marque;
    		this.timer = timer;
     
    		if(l.length > 2 && l.length < 21)
    		{
    			this.tabLed = l;
    		}
     
    		else if(l.length > 20)
    		{
    			this.tabLed = new Led[20];
    		}
     
    		else if(l.length < 3)
    		{
    			this.tabLed = new Led[3];
    		}
     
    		else
    		{
    			int i2 = 0;
     
    			for(int i = 0; i < l.length; i++)
    			{
    				this.tabLed[i] = l[i];
    				i2++;
    			}
     
    			for(int i = i2; i < 3; i++)
    			{
    				this.tabLed[i] = new Led();
    			}
    		}
    	}
     
    	public Spot()
    	{
    		this.tabLed = new Led[3];
    		this.timer = new Timer();
     
    	}
     
    	public Spot(Spot s)
    	{
    		this.marque = s.getMarque();
    		this.timer = s.getTimer();
    		this.tabLed = new Led[s.tabLed.length];
     
    		for (int i = 0; i < s.tabLed.length; i++)
    		{
    			this.tabLed[i] = s.tabLed[i];
    		}
    	}
     
    	public void allumer()
    	{
    		for(int i = 0; i < this.tabLed.length; i++)
    		{
    			this.tabLed[i].allumer();
    		}
    	}
     
    	public void eteindre()
    	{
    		for(int i = 0; i < this.tabLed.length; i++)
    		{
    			this.tabLed[i].eteindre();
    		}
    	}
     
    	public void clignoter()
    	{
    		for(int i = 0; i < this.tabLed.length; i++)
    		{
    			this.tabLed[i].clignoter();
    		}
    	}
     
    	public void cycle(int nB)
    	{
    		this.timer.activer();		
     
    		for(int j = 0; j < nB; j++)
    		{
    			for(int i = 0; i < this.tabLed.length; i++)
    			{
    				this.tabLed[i].clignoter();
    				System.out.println(this);
    				this.timer.utiliser();
     
    			}
     
     
    		}
     
    		this.timer.desactiver();
    	}
     
    	public void init()
    	{
    		Scanner input = new Scanner(System.in);
    		System.out.println("Marque du Spot?");
    		this.marque = input.nextLine();
     
    		this.timer = new Timer();
    		this.timer.init();
     
    		int n = 0;
    		System.out.println("Nombre de leds?");
    		n = input.nextInt();
     
    		this.tabLed = new Led[n];
     
    		for(int i = 0; i < n; i++)
    		{
    			this.tabLed[i] = new Led();
    			this.tabLed[i].init();
    		}
     
     
     
    	} 
     
    	public String toString()
    	{
    		String s = this.getMarque();		
     
    		for(int i = 0; i < this.tabLed.length; i++)
    		{
    			s = s + tabLed[i];	
     
    		}
     
    		return s;
    	}
     
    }

    Mon programme test,

    Code java : 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
    public class TestSpot
    {
    	public static void main(String[]args)
    	{
    		Spot spot = new Spot();
    		spot.toString();
     
    		spot.init();
    		spot.toString();
     
    		Led[] l = { new Led(1234, true), new Led(4567, false), new Led(8910, true)};
     
     
    		Led[] tabLed = new Led[5];
    		Spot spot1 = new Spot("Strumpfel", tabLed, 2000);
     
     
     
     
     
    		spot1.cycle(3);
     
    		spot1.eteindre();
     
    		Spot spot2 = new Spot(spot1);
     
    		spot1.allumer();
     
    		spot1.toString();
    		spot2.toString();
     
     
     
    	}
    }

    Mon erreur de compilation est la suivante,

    TestSpot.java:15: cannot find symbol
    symbol : constructor Spot(java.lang.String,Led[],int)
    location: class Spot
    Spot spot1 = new Spot("Strumpfel", tabLed, 2000);
    ^
    1 error


    Une idée?

  2. #2
    Membre Expert Avatar de Ivelios
    Homme Profil pro
    Développeur Java
    Inscrit en
    Juillet 2008
    Messages
    1 031
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 031
    Par défaut
    Bonjour :

    Ton constructeur actuel :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    public Spot(String marque, Led[]l, Timer timer)
    Et tu l'appel comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    new Spot("Strumpfel", tabLed, 2000);
    "2000" est un entier et non un Timer !

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2011
    Messages
    45
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2011
    Messages : 45
    Par défaut
    Merci ça compile impec maintenant, c'était pourtant évident!

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

Discussions similaires

  1. problème de compilation sous visual C++
    Par fabmili dans le forum MFC
    Réponses: 4
    Dernier message: 08/02/2004, 19h52
  2. problème de compil devc++ socket
    Par stefdem dans le forum Autres éditeurs
    Réponses: 2
    Dernier message: 11/12/2003, 11h33
  3. Réponses: 1
    Dernier message: 29/10/2003, 12h16
  4. Problème de compilation de la DLL du XMLRad
    Par [DreaMs] dans le forum XMLRAD
    Réponses: 2
    Dernier message: 16/04/2003, 16h46
  5. Réponses: 1
    Dernier message: 27/05/2002, 01h44

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