Bookmark Topic Watch Topic
  • New Topic

Iteration within a collection  RSS feed

 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have a situation. I need to create an iteration one that uses a while loop because I don't want to get into the for loop. Basically I have a class called Club. I have an array list that will allow the user to add "members" to the club. I also have methods to return the value of members joined, a method to see how many joined within a month, and one within a year. To actually join "members", a constructor gets it and asks for the name the month and the year. Then that member is joined. However, now I need to create another array: public ArrayList<Membership> purge(int month, int year) that will ask for the month and year. This is where it will "purge" all the users within that month and year, which will remove them. After that, it will return those members to me that are being removed... so I guess this should be right before they actually get removed. So, return, and then remove. Any idea how to do this using a while?
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Report post to moderator
In other words... the user has to to input a month. Everything within that month will be removed. How can I code this?
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Report post to moderator
I can only get as far as here:
public ArrayList<Membership> purge(int month, int year)
{
while ()
{

return purge;
}
}
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
is this thread different from this thread? it doesn't appear to be, so i'm going to close this as a duplicate. please continue the discussion over there.
[ November 21, 2006: Message edited by: fred rosenberger ]
 
Martin vanPutten
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Report post to moderator
Same idea, but things have changed a bit actually. I can't use a for loop either. Do you have any idea?
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!