Lab06

6th lab at 21.10.2024

Iterable/Iterator interfaces, repetition

Base project

Use project at https://gitlab.vsb.cz/jez04-vyuka/java-efrei/efrei-lab06.git as a base to complete the following tasks.

Import to Eclipse:

  • File -> Import... -> project from Git (with smart import) -> Clone URI -> (use above link as URI) -> Next -> Next -> Finish

Open in InteliJ IDEA:

  • File -> New -> Project from Version Control... -> (use above link as URL) -> Clone

Tasks

  • Create class World which has collection of Heroes and other collection of Monsters.
  • Initialize collections of heroes and monsters from class World in constructor. Generate random number of monsters and herors.
  • Ensure that class World implements interface Iterable.
  • Create inner class which implements interface Iterator and ensure, that object of this class will be returned in method World::iterator().
  • Ensure that method remove() from interface Iterator will be overridden and implemented to allow remove elements during iteration.

Solution

solution can be found in project original project in branche solution