-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitrefactor.txt
111 lines (109 loc) · 3.28 KB
/
gitrefactor.txt
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
diff --git a/src/clueGame/Board.java b/src/clueGame/Board.java
index 937b544..2f83d27 100644
--- a/src/clueGame/Board.java
+++ b/src/clueGame/Board.java
@@ -38,15 +38,10 @@ public class Board {
public void initialize() {
try {
this.loadSetupConfig();
- }
- catch (BadConfigFormatException e) {
- System.out.println("Bad format in file " + layoutConfigFile);
- }
- try {
this.loadLayoutConfig();
- }
+ }
catch (BadConfigFormatException e) {
- System.out.println("Bad format in file " + setupConfigFile);
+ System.out.println("Bad format in file(s)");
}
}
@@ -63,34 +58,39 @@ public class Board {
Scanner in=new Scanner(reader);
char character;
String roomName;
- String type;
+ String roomType;
String line=in.nextLine();
while (in.hasNextLine()) {
if (!(line.charAt(0)== '/')) {
- String[] parts = line.split(", ");
- type = parts[0];
- // Throw exception if type is not Room or Space
- if (!(type.equals("Room")) && !(type.equals("Space"))) {
- throw new BadConfigFormatException();
- }
- roomName = parts[1];
- character = parts[2].charAt(0);
- Room room = new Room(roomName, character);
- roomMap.put(character, room);
+ getRoomInformation(line);
}
line=in.nextLine();
}
- String[] parts = line.split(", ");
- type = parts[0];
- roomName = parts[1];
- character = parts[2].charAt(0);
- Room room = new Room(roomName, character);
- roomMap.put(character, room);
+ getRoomInformation(line);
in.close();
} catch (FileNotFoundException e) {
System.out.println("Could not find " + setupConfigFile);
}
}
+
+ /*
+ * From line, extract information about room or space and put it into roomMap
+ */
+ private void getRoomInformation(String line) {
+ char character;
+ String roomName;
+ String type;
+ String[] parts = line.split(", ");
+ type = parts[0];
+ // Throw exception if type is not Room or Space
+ if (!(type.equals("Room")) && !(type.equals("Space"))) {
+ throw new BadConfigFormatException();
+ }
+ roomName = parts[1];
+ character = parts[2].charAt(0);
+ Room room = new Room(roomName, character);
+ roomMap.put(character, room);
+ }
//load our csv file, so we know where our rooms are, where our center etc.
public void loadLayoutConfig() {
@@ -124,11 +124,6 @@ public class Board {
}
if (cellData.length()==1) {
cell.setInitial(cellData.charAt(0));
- cell.setDoorDirection(DoorDirection.NONE);
- cell.setIsOccupied(false);
- cell.setRoomCenter(false);
- cell.setRoomLabel(false);
- cell.setIsDoorway(false);
// Test if cell is a walkway or unused space
if (!cellData.equals("W") && !cellData.equals("X")) {
cell.setIsRoom(true);
@@ -142,9 +137,6 @@ public class Board {
char specChar=cellData.charAt(1);
cell.setInitial(name);
if (name == 'W') {
- cell.setIsRoom(false);
- cell.setRoomCenter(false);
- cell.setRoomLabel(false);
cell.setIsDoorway(true);
switch(specChar) {
case '<':
@@ -222,7 +214,8 @@ public class Board {
public int getNumRooms() {
return roomMap.size();
}
-
+
+ // Getter for roomMap variable
public Map<Character, Room> getRoomMap() {
return roomMap;
}