-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhovedprogram.java
More file actions
43 lines (40 loc) · 1.35 KB
/
hovedprogram.java
File metadata and controls
43 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
class Oblig5 {
public static void main(String[] args)throws Exception {
String filnavn = null;
if (args.length > 0) {
filnavn = args[0];
} else {
System.out.println("FEIL! Riktig bruk: "
+"java Oblig5 <labyrintfil>");
return;
}
File fil = new File(filnavn);
Labyrint l = null;
try {
l = Labyrint.lesFraFil(fil);
} catch (FileNotFoundException e) {
System.out.printf("FEIL: Kunne ikke lese fra '%s'\n", filnavn);
System.exit(1);
}
//l.settMinimalUtskrift();
// les start-koordinater fra standard input
Scanner inn = new Scanner(System.in);
while (inn.hasNextLine()) {
String[] ord = inn.nextLine().split(" ");
int startKol = Integer.parseInt(ord[0]);
int startRad = Integer.parseInt(ord[1]);
Liste<String> utveier = l.finnUtveiFra(startKol, startRad);
if (!utveier.erTom()) {
for (String s : utveier) {
System.out.println(s);
}
} else {
System.out.println("Ingen utveier.");
}
System.out.println();
}
}
}