import java.io.*; import java.util.*; public class Meny implements MenyInterface{ protected Savanne savanne; Meny(){ skrivMeny(); } public void skrivMeny(){ while(true){ System.out.println("1: Les inn Savanne fra fil."); System.out.println("2: Print Savanne."); System.out.println("3: Finn loven."); System.out.println(" "); System.out.println("0: Exit"); taValg(); } } public int taInput(){ Scanner s = new Scanner(System.in); int valg = s.nextInt(); return valg; } public void taValg(){ int valg = taInput(); switch (valg){ case 1: lesFil(); break; case 2: printSavanne(); break; case 3: finnLove(); break; case 0: System.out.println("Avslutter..."); System.exit(0); default: System.out.println("Ugldig input."); } } public void lesFil(){ System.out.println("Hvilken fil skal leses?"); Scanner in = new Scanner(System.in); LesFil lf = new LesFil(in.nextLine()); try{ savanne = lf.lesFil(); }catch (FileNotFoundException e){ System.out.println("Filen finnes ikke. Avslutter..."); System.exit(0); } } public void printSavanne(){ savanne.printSavanne(); } public void finnLove(){ savanne.finnLove(); } }