I tried the public JobHistory(String name, int[] months) {...}
together with the HashMaps  but couldn't get it to work.

What I do have something is this.

while (rs.next()) {
    String username = rs.getString("username");
    int jobcount =  rs.getInt("jobcount");

    int found = 0;
    for (int v = 0; v< values.size(); v++) {
        JobHistory jh = values.get(v);
        if (jh.name.compareTo(username) == 0) {
            found = 1;
            jh.setMonthData(n, jobcount);
            values.set(v, jh);
        }
    }
    if ( found == 0) {
        values.add( new JobHistory(username,n,jobcount));
    }
}

And in my JobHistory class I have added:

a constructor:
    public JobHistory(String username, int mon, int jobcount) {
     // which is a 12-item switch/case statement
    }
a method:
    public void setMonthData(int mon, int jobcount) {
     // ALSO a 12-item switch/case statement
    }

Alan

On Sep 11, 9:41 am, Christian Catchpole <[EMAIL PROTECTED]>
wrote:
> yes, i was thinking that, if you don't need to track more than 1
> months data per object, this is the way to go.
>
> On Sep 11, 4:27 pm, amiller <[EMAIL PROTECTED]> wrote:
>
> > Christian,
>
> > would I create my JobHistory class like this:
>
> >  public JobHistory(String name, int[] months) {
> >         this.name = name;
> >         this.months = months;
> >  }
> >  public int getMonthData(int mon) {
> >         return months[mon];
> >  }
> >  public void setMonthData(int mon, int data) {
> >         this.months[mon] = data;
> >  }
>
> > On Sep 11, 7:17 am, "Wayne Fay" <[EMAIL PROTECTED]> wrote:
>
> > > Since we're picking on you... ;-)
>
> > > On Wed, Sep 10, 2008 at 9:03 PM, Michael Burgess <[EMAIL PROTECTED]> 
> > > wrote:
> > > >        } else {
> > > >            values.set(n, jobcount);
>
> > >               jobHistory.put(username, values);
>
> > > (I'm only sending this because I'm concerned Alan may use some of this
> > > as-is, and get annoyed when his values don't update properly...)
>
> > > Wayne
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to