1
+ /**
2
+ * SWEN30006 Software Modelling and Design
3
+ * Semester 1, 2017
4
+ * Project Part B - Metro Madness
5
+ *
6
+ * Group 107
7
+ * Members:
8
+ * Nate Wangsutthitham
9
+ * Kolatat Thangkasemvathana [7
10
+ * Khai Mei Chin
11
+ *
12
+ */
13
+
1
14
package com .unimelb .swen30006 .metromadness ;
2
15
3
16
import java .util .ArrayList ;
26
39
import com .unimelb .swen30006 .metromadness .trains .passenger .SmallPassengerTrain ;
27
40
import com .unimelb .swen30006 .metromadness .trains .Train ;
28
41
42
+ /**
43
+ * [SWEN30006] Software Modelling and Design
44
+ * Semester 1, 2017
45
+ * Project Part B - Metro Madness
46
+ *
47
+ * Group 107:
48
+ * Nate Wangsutthitham [755399]
49
+ * Kolatat Thangkasemvathana [780631]
50
+ * Khai Mei Chin [755332]
51
+ *
52
+ */
53
+
29
54
public class MapReader {
30
55
31
- public ArrayList <Train > trains ;
32
- public HashMap <String , Station > stations ;
33
- public HashMap <String , Line > lines ;
56
+ private ArrayList <Train > trains ;
57
+ private HashMap <String , Station > stations ;
58
+ private HashMap <String , Line > lines ;
34
59
35
- public boolean processed ;
36
- public String filename ;
60
+ private boolean processed ;
61
+ private String filename = "../core/assets/maps/melbourne_cargo.xml" ;
62
+ //private String filename = "../core/assets/maps/melbourne.xml";
63
+ //private String filename = "../core/assets/maps/world.xml";
37
64
38
65
public MapReader (String filename ){
39
66
this .trains = new ArrayList <Train >();
@@ -46,9 +73,9 @@ public MapReader(String filename){
46
73
public void process (){
47
74
try {
48
75
// Build the doc factory
49
- FileHandle file = Gdx .files .internal ("../core/assets/maps/melbourne_cargo.xml" );
76
+ // FileHandle file = Gdx.files.internal("../core/assets/maps/melbourne_cargo.xml");
50
77
//FileHandle file = Gdx.files.internal("../core/assets/maps/melbourne.xml");
51
- // FileHandle file = Gdx.files.internal("../core/assets/maps/world.xml");
78
+ FileHandle file = Gdx .files .internal ("../core/assets/maps/world.xml" );
52
79
XmlReader reader = new XmlReader ();
53
80
Element root = reader .parse (file );
54
81
@@ -57,15 +84,15 @@ public void process(){
57
84
Array <Element > stationList = stations .getChildrenByName ("station" );
58
85
for (Element e : stationList ){
59
86
Station s = processStation (e );
60
- this .stations .put (s .name , s );
87
+ this .stations .put (s .getName () , s );
61
88
}
62
89
63
90
// Process Lines
64
91
Element lines = root .getChildByName ("lines" );
65
92
Array <Element > lineList = lines .getChildrenByName ("line" );
66
93
for (Element e : lineList ){
67
94
Line l = processLine (e );
68
- this .lines .put (l .name , l );
95
+ this .lines .put (l .getName () , l );
69
96
}
70
97
71
98
// Process Trains
@@ -145,6 +172,11 @@ private Station processStation(Element e){
145
172
}
146
173
}
147
174
175
+ /**
176
+ * Parses input document to get information of train Lines
177
+ * @param e
178
+ * @return
179
+ */
148
180
private Line processLine (Element e ){
149
181
Color stationCol = extractColour (e .getChildByName ("station_colour" ));
150
182
Color lineCol = extractColour (e .getChildByName ("line_colour" ));
0 commit comments