import java.util.*; public class Program{ public static void main(String[] args) { Safe safe = new Safe("Mine hemmeligheter", 1234); Scanner in = new Scanner(System.in); String input; String innhold; int kode; boolean locked = true; while(locked){ System.out.println("Tast inn riktig kode: "); input = in.nextLine(); try{ kode = Integer.parseInt(input); innhold = safe.hentInnhold(kode); System.out.println("Innholdet er: " + innhold); System.out.println("Safen er ?pnet!"); locked = false; } catch (MittUnntak u){ System.out.println(u.getMessage()); } catch (NumberFormatException e){ System.out.println("Koden tastet inn er ikke et tall!"); } finally{ System.out.println(); } } } }