Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Iteration within a collection

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I can only get as far as here:
public ArrayList<Membership> purge(int month, int year)
{
while ()
{

return purge;
}
}
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic