@Test public void testCountMoons() throws Exception { WorldCounter counter = new WorldCounter(); Map<String,Integer> result = counter.countMoons(asList(new World("earth", 1))); assertEquals("earth has one moon",(Integer)1,result.get("earth")); }
public Map<String, Integer> countMoons(Iterable<World> worlds) { Map<String, Integer> moons = new HashMap<String, Integer>(); for (World world : worlds) { moons.put(world.getName(), world.getMoons()); } return moons; }
WorldCounter { public Map<String, Integer> countMoons(Iterable<World> worlds) { Map<String, Integer> moons = new HashMap<String, Integer>(); for (World world : worlds) { moons.put(world.getName(), world.getMoons()); } return moons; } }
WorldCounter { public Map<String, Integer> countMoons(Iterable<World> worlds) { Map<String, Integer> moons = new HashMap<String, Integer>(); for (World world : worlds) { moons.put(world.getName(), world.getMoons()); } return moons; }  }
WorldCounter { public Map<String, Integer> countMoons(Iterable<World> worlds) { Map<String, Integer> moons = new HashMap<String, Integer>(); for (World world : worlds) { moons.put(world.getName(), world.getMoons()); } return moons; }  Map<String, Integer> countMoons(Iterable<World> worlds); }
WorldCounter { public Map<String, Integer> countMoons(Iterable<World> worlds) { Map<String, Integer> moons = new HashMap<String, Integer>(); for (World world : worlds) { moons.put(world.getName(), world.getMoons()); } return moons; }  Map<String, Integer> countMoons(Iterable<World> worlds);  }