-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.java
More file actions
95 lines (90 loc) · 2.45 KB
/
Map.java
File metadata and controls
95 lines (90 loc) · 2.45 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* Written by Junyoung Justin Kim */
/* lawsonNavigator-server */
/* Map file reading */
/* Last Update : Nov, 1 */
import java.io.*;
import java.util.*;
public class Map{
public static void main(String[] args) {
int col = 27; // There are 27 columns in the map file
int row = 61; // There is 61 rows in the map file
int floorB[][] = new int[col][row]; // basement floor
int floor1[][] = new int[col][row]; // 1st floor
int floor2[][] = new int[col][row]; // 2nd floor
int floor3[][] = new int[col][row]; // 3rd floor
int i, j, temp; // i, j for array index to reading file
File fileB = new File ("floorB.txt");
File file1 = new File ("floor1.txt");
File file2 = new File ("floor2.txt");
File file3 = new File ("floor3.txt");
Scanner scanB;
Scanner scan1;
Scanner scan2;
Scanner scan3;
try {
scanB = new Scanner (fileB);
scan1 = new Scanner (file1);
scan2 = new Scanner (file2);
scan3 = new Scanner (file3);
// Reading Basement floor
i = 0; j = 0;
while (scanB.hasNextInt()) {
temp = scanB.nextInt();
floorB[i][j] = current; i++;
if (i == col){ j++; i = 0; }
}
// Reading 1st Floor
i = 0; j = 0;
while (scan1.hasNextInt()) {
temp = scan1.nextInt();
floor1[i][j] = current; i++;
if (i == col){ j++; i = 0; }
}
// Reading 2nd Floor
i = 0; j = 0;
while (scan2.hasNextInt()) {
temp = scan2.nextInt();
floor2[i][j] = current; i++;
if (i == col){ j++; i = 0; }
}
// Reading 3rd Floor
i = 0; j = 0;
while (scan3.hasNextInt()) {
temp = scan3.nextInt();
floor3[i][j] = current; i++;
if (i == col){ j++; i = 0; }
}
} catch (Exception e){
}
// -------------------------- Printing Part (Just for varification) --------------------------
/*
System.out.println("Basement");
for (int k = 0; k < row; k++){
for (int l = 0; l < col; l++){
System.out.printf("%d", floorB[l][k]);
}
System.out.println();
}
System.out.println("1st");
for (int k = 0; k < row; k++){
for (int l = 0; l < col; l++){
System.out.printf("%d", floor1[l][k]);
}
System.out.println();
}
System.out.println("2nd");
for (int k = 0; k < row; k++){
for (int l = 0; l < col; l++){
System.out.printf("%d", floor2[l][k]);
}
System.out.println();
}
System.out.println("3rd");
for (int k = 0; k < row; k++){
for (int l = 0; l < col; l++){
System.out.printf("%d", floor3[l][k]);
}
System.out.println();
}*/
}
}