Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterator?  RSS feed

 
Lari Hopkins
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have successfully created an arraylist that now has data read into it-a big thankyou to those that helped me along the way. Since then I have been attempting to use my group 1 methods to get this data back out when required. For example a
String getMake(String reg)
method.

(Also String getModel(String reg), String getColour(String reg) etc)

I think I need to use an Iterator to do this but I'm not sure how. I have begun by using SimpleIO..

String name = SimpleIO.getString ("Press 1 for group 1 methods");
while (ans.equals ("1") {

leaving me struggling to find the code for initialising the getMake method, and indeed using it.

Any assistance will be very helpful.
 
Lari Hopkins
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone out there who can help? I'm still having trouble with this
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Do you mean you want to go through all of the Objects in your list and call these getter methods?

John
 
Lari Hopkins
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three arraylists (car, bike and service) and I need to searh car and bike for the make of a vehicle with a particular reg number. Should I construct a getMake method in my car and bike classes, or ask whether it is a car/bike first and then search the relevant list? I have a SimpleIO msg asking for the reg no but i don't know how to refer back to the arraylist and construct a method.
 
John Bartlett
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
couldnt you just use a loop?



Not sure whether this will meet your requirements as dont really have much to go on.

John
[ January 25, 2007: Message edited by: John Bartlett ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!