Help I don't know how else to do it
package pl.codegym.task.task09.task0927;
import java.util.*;
/*
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() {
//tutaj wpisz swój kod
Map<String, Kot> kotMap = new HashMap<>();
Kot kot = new Kot("Paweł");
kotMap.put(kot.imie, kot);
Kot kot1 = new Kot("Paweł1");
kotMap.put(kot1.imie, kot);
Kot kot2 = new Kot("Paweł2");
kotMap.put(kot2.imie, kot);
Kot kot3 = new Kot("Paweł3");
kotMap.put(kot3.imie, kot);
Kot kot4 = new Kot("Paweł4");
kotMap.put(kot4.imie, kot);
Kot kot5 = new Kot("Paweł5");
kotMap.put(kot5.imie, kot);
Kot kot6 = new Kot("Paweł6");
kotMap.put(kot6.imie, kot);
Kot kot7 = new Kot("Paweł7");
kotMap.put(kot7.imie, kot);
Kot kot8 = new Kot("Paweł8");
kotMap.put(kot8.imie, kot);
Kot kot9 = new Kot("Paweł9");
kotMap.put(kot9.imie, kot);
return kotMap;
}
public static Set<Kot> konwertujMapDoSet(Map<String, Kot> mapa) {
//tutaj wpisz swój kod
Set<String> keySet = mapa.keySet();
Collection<Kot> values = mapa.values();
// Set<Map.Entry<String, Kot>> entrySet = mapa.entrySet();
Set set = new TreeSet<Map.Entry<String, Kot>>();
for (int i = 0; i < mapa.size(); i++)
{
set.add(new AbstractMap.SimpleEntry<Set, Collection>(keySet, values));
}
return set;
}
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;
}
}
}