import java.util.HashMap; public class Program { public static void main(String[] args) { HashMap map = new HashMap<>(); Bil bil = new Bil("1", "BMW", "123", 2001, 5); Bil bil2 = new Bil("2", "Alfa Romeo", "gulia", 2017, 5); Motorsykkel motorsykkel = new Motorsykkel("3", "Harley", "345", 2024, "liten"); Motorsykkel motorsykkel2 = new Motorsykkel("4", "Volvo", "af1", 2010, "Sykt stor"); map.put(bil.hentId(), bil); map.put(bil2.hentId(), bil2); map.put(motorsykkel.hentId(), motorsykkel); map.put(motorsykkel2.hentId(), motorsykkel2); for(Kjoretoy k : map.values()){ System.out.println("Id "+ k.hentId()); System.out.println("Merke " + k.hentMerke()); System.out.println("Modell " + k.hentModell()); System.out.println("?r " + k.hentAar()); if (k instanceof Bil){ System.out.println("Seter " +((Bil) k).hentSeter()); } if (k instanceof Motorsykkel){ System.out.println("Motortype "+ ((Motorsykkel) k).hentMotorType()); } System.out.println(); } } }