Tak jak w temacie, nie rozumiem ostatniego podpunktu, proszę o jakieś wskazówki
package pl.codegym.task.task09.task0927;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/*
Dziesięć kotów
*/
public class Solution {
public static void main(String[] args) {
Map<String, Kot> mapa = utworzMap();
Set<Kot> set = konwertujMapDoSet(mapa);
printSetKotow(set);
}
public static Map<String, Kot> utworzMap() {
HashMap<String, Kot> koty = new HashMap<String, Kot>();
Kot kot = new Kot("Jacek");
koty.put(kot.imie, kot);
Kot kot2 = new Kot("Jacek1");
koty.put(kot2.imie, kot2);
Kot kot3 = new Kot("Jacek2");
koty.put(kot3.imie, kot3);
Kot kot4 = new Kot("Jacek3");
koty.put(kot4.imie, kot4);
Kot kot5 = new Kot("Jacek4");
koty.put(kot5.imie, kot5);
Kot kot6 = new Kot("Jacek5");
koty.put(kot6.imie, kot6);
Kot kot7 = new Kot("Jacek6");
koty.put(kot7.imie, kot7);
Kot kot8 = new Kot("Jacek7");
koty.put(kot8.imie, kot8);
Kot kot9 = new Kot("Jacek8");
koty.put(kot9.imie, kot9);
Kot kot10 = new Kot("Jacek9");
koty.put(kot10.imie, kot10);
return koty;
}
public static Set<Kot> konwertujMapDoSet(Map<String, Kot> mapa) {
HashMap<String, Kot> kopia = new HashMap<String, Kot>(mapa);
Set secikKey = new HashSet<String>();
Set secikValue = new HashSet<String>();
for(Map.Entry<String, Kot> para : kopia.entrySet()){
secikKey.add(para.getKey());
secikValue.add(para.getValue());
}
return secikValue;
}
public static void printSetKotow(Set<Kot> set) {
for (Kot kot : set) {
System.out.println(kot);
}
}
public static class Kot {
private String imie;
public Kot(String imie) {
this.imie = imie;
}
public String toString() {
return "Kot " + this.imie;
}
}
}