Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public StringIterable copyRaces() {
- ArrayList<String> races = new ArrayList<String>();
- for(Participation part: this)
- {
- String race =part.getRace();
- boolean found = false;
- for(int i=0; i < races.size();i++)
- {
- if(race.equals(races.get(i)) )
- {
- found = true;
- break;
- }
- }
- if(!found)
- races.add(race);
- }
- return new StringIter(races);
- }
- -----------------------------------------------------------
- public class StringIDK implements StringIterator {
- public int index = 0;
- public ArrayList<String> list;
- public StringIDK(ArrayList<String> list)
- {
- this.list = list;
- }
- @Override
- public String next()
- {
- if(hasNext())
- {
- return list.get(index++);
- }
- throw new NoSuchElementException();
- }
- @Override
- public boolean hasNext()
- {
- return index < list.size();
- }
- }
- ---------------------------------------
- public class StringIter implements StringIterable {
- ArrayList<String> list;
- public StringIter(ArrayList<String> list)
- {
- this.list = list;
- }
- @Override
- public StringIterator iterator()
- {
- return new StringIDK(list);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement