BluJ besoin d'aide!!!!

Ruydo Messages postés 4 Date d'inscription jeudi 22 novembre 2007 Statut Membre Dernière intervention 1 décembre 2007 - 29 nov. 2007 à 16:56
Ruydo Messages postés 4 Date d'inscription jeudi 22 novembre 2007 Statut Membre Dernière intervention 1 décembre 2007 - 1 déc. 2007 à 11:06
Bonjour tout le monde, voila j'ai un petit probleme, je dois creer une method qui me permet de lister tout les elements de mon "ArrayList" , dans mon cas le but est de lister toute les zones que j'ai stocke precedement. Le probleme est que je recois des messages bizarre au lieu des zones, jugez par vous meme :





<!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:232.5pt;
height:166.5pt'>
<v:imagedata src="file:///C:\DOCUME~1\hii0017\LOCALS~1\Temp\msohtml1\01\clip_image001.png"
o:title=""/>
</v:shape><![endif]-->
<!--[if !vml]-->




Et voici mon code:
import java.util.ArrayList;
import java.util.Iterator;

/**
 * The ClockDisplay class implements a digital clock display for a
 * European-style 24 hour clock. The clock shows hours and minutes. The
 * range of the clock is 00:00 (midnight) to 23:59 (one minute before
 * midnight).
 *
 * The clock display receives "ticks" (via the timeTick method) every minute
 * and reacts by incrementing the display. This is done in the usual clock
 * fashion: the hour increments when the minutes roll over to zero.
 *
 * @author Michael Kolling and David J. Barnes
 * @version 2006.03.30
 */
public class ClockDisplay
{
    private NumberDisplay hours;
    private NumberDisplay minutes;
    private String displayString;    // simulates the actual display
    private ArrayList<Zone> zones;
    private int capacity;

   
    /**
     * Constructor for ClockDisplay objects. This constructor
     * creates a new clock set at 00:00.
     */
   
                       
   
    public ClockDisplay()
    {
        hours = new NumberDisplay(24);
        minutes = new NumberDisplay(60);
        updateDisplay();
       
    }

    /**
     * Constructor for ClockDisplay objects. This constructor
     * creates a new clock set at the time specified by the
     * parameters.
     */
    public ClockDisplay(int hour, int minute, int maxNumberOfZones)
    {
       zones = new ArrayList<Zone>();
       hours = new NumberDisplay(24);
       minutes = new NumberDisplay(60);
       setTime(hour, minute);
       capacity = maxNumberOfZones;
    }

    public void storeZone(Zone newZone)
    {
        if(zones.size() == capacity) {
              System.out.println("Error");
    }
    else {
        zones.add(newZone);
    }
}
    public int numberOfZones()
    {
        return zones.size();
    }
   
   
    /**
     * This method should get called once every minute - it makes
     * the clock display go one minute forward.
     */
    public void timeTick()
    {
        minutes.increment();
        if(minutes.getValue() == 0) {  // it just rolled over!
            hours.increment();
        }
        updateDisplay();
    }

    /**
     * Set the time of the display to the specified hour and
     * minute.
     */
    public void setTime(int hour, int minute)
    {
        hours.setValue(hour);
        minutes.setValue(minute);
        updateDisplay();
    }

    /**
     * Return the current time of this display in the format HH:MM.
     */
    public String getTime()
    {
        return displayString;
    }
   
    /**
     * Update the internal string that represents the display.
     */
    private void updateDisplay()
    {
        displayString = hours.getDisplayValue() + ":" +
                        minutes.getDisplayValue();
    }
  
   
    /**
     * List all zones that have been stored
     */
   
    public void printZone()
    {
    Iterator<Zone> it = zones.iterator();
    while(it.hasNext()) {
        System.out.println("Time zones are:");
        System.out.println(it.next());
    }
}  
}

Toute aide serais grandement apprecier...
  
   

<!--[endif]-->

2 réponses

Utilisateur anonyme
30 nov. 2007 à 22:10
Premièrement, tu n'as pas besoin d'un itérateur, tu peux utiliser la nouvelle boucle for. Le problème vient peut-être du fait que tu n'as peut-être pas écrit de méthode toString pour la classe Zone, donc ça utilise celle de la classe Object.

TUER : http://tuer.tuxfamily.org/tuer.php

yeah! vive java
0
Ruydo Messages postés 4 Date d'inscription jeudi 22 novembre 2007 Statut Membre Dernière intervention 1 décembre 2007
1 déc. 2007 à 11:06
Ok merci je vais essayer  meme si j'ai remis mon travail hier  
0
Rejoignez-nous