Skip to content

Commit 86dbab9

Browse files
authored
Merge pull request #14 from natebwangsut/develop
Develop
2 parents b090095 + 7c86464 commit 86dbab9

27 files changed

+662
-249
lines changed

core/assets/maps/melbourne_cargo.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@
274274
<max_passengers> 100 </max_passengers>
275275
</station>
276276
<station>
277-
<type>Cargo</type>
277+
<type>Active</type>
278278
<name>Williamstown</name>
279279
<x_loc>1840</x_loc>
280280
<y_loc>4200</y_loc>
281281
<router>simple</router>
282282
<max_passengers> 100 </max_passengers>
283283
</station>
284284
<station>
285-
<type>Active</type>
285+
<type>Cargo</type>
286286
<name>Newport</name>
287287
<x_loc>1840</x_loc>
288288
<y_loc>4700</y_loc>
@@ -292,8 +292,8 @@
292292
<station>
293293
<type>Active</type>
294294
<name>Seaholme</name>
295-
<x_loc>1840</x_loc>
296-
<y_loc>4700</y_loc>
295+
<x_loc>1000</x_loc>
296+
<y_loc>4200</y_loc>
297297
<router>simple</router>
298298
<max_passengers> 100 </max_passengers>
299299
</station>
@@ -981,7 +981,7 @@
981981
<train>
982982
<type>BigCargo</type>
983983
<line>Williamstown</line>
984-
<start>Williamstown</start>
984+
<start>Newport</start>
985985
<name>Amtrak</name>
986986
<direction>forward</direction>
987987
</train>

core/src/com/unimelb/swen30006/metromadness/MapReader.java

+41-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
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+
114
package com.unimelb.swen30006.metromadness;
215

316
import java.util.ArrayList;
@@ -26,14 +39,28 @@
2639
import com.unimelb.swen30006.metromadness.trains.passenger.SmallPassengerTrain;
2740
import com.unimelb.swen30006.metromadness.trains.Train;
2841

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+
2954
public class MapReader {
3055

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;
3459

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";
3764

3865
public MapReader(String filename){
3966
this.trains = new ArrayList<Train>();
@@ -46,9 +73,9 @@ public MapReader(String filename){
4673
public void process(){
4774
try {
4875
// 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");
5077
//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");
5279
XmlReader reader = new XmlReader();
5380
Element root = reader.parse(file);
5481

@@ -57,15 +84,15 @@ public void process(){
5784
Array<Element> stationList = stations.getChildrenByName("station");
5885
for(Element e : stationList){
5986
Station s = processStation(e);
60-
this.stations.put(s.name, s);
87+
this.stations.put(s.getName(), s);
6188
}
6289

6390
// Process Lines
6491
Element lines = root.getChildByName("lines");
6592
Array<Element> lineList = lines.getChildrenByName("line");
6693
for(Element e : lineList){
6794
Line l = processLine(e);
68-
this.lines.put(l.name, l);
95+
this.lines.put(l.getName(), l);
6996
}
7097

7198
// Process Trains
@@ -145,6 +172,11 @@ private Station processStation(Element e){
145172
}
146173
}
147174

175+
/**
176+
* Parses input document to get information of train Lines
177+
* @param e
178+
* @return
179+
*/
148180
private Line processLine(Element e){
149181
Color stationCol = extractColour(e.getChildByName("station_colour"));
150182
Color lineCol = extractColour(e.getChildByName("line_colour"));

core/src/com/unimelb/swen30006/metromadness/MetroMadness.java

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
1515
import com.badlogic.gdx.math.MathUtils;
1616

17+
/**
18+
* [SWEN30006] Software Modelling and Design
19+
* Semester 1, 2017
20+
* Project Part B - Metro Madness
21+
*
22+
* Group 107:
23+
* Nate Wangsutthitham [755399]
24+
* Kolatat Thangkasemvathana [780631]
25+
* Khai Mei Chin [755332]
26+
*
27+
*/
28+
1729
public class MetroMadness extends ApplicationAdapter {
1830

1931
// The width of the world in unitless dimensions

core/src/com/unimelb/swen30006/metromadness/Simulation.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@
1010
import com.unimelb.swen30006.metromadness.tracks.Line;
1111
import com.unimelb.swen30006.metromadness.trains.Train;
1212

13+
/**
14+
* [SWEN30006] Software Modelling and Design
15+
* Semester 1, 2017
16+
* Project Part B - Metro Madness
17+
*
18+
* Group 107:
19+
* Nate Wangsutthitham [755399]
20+
* Kolatat Thangkasemvathana [780631]
21+
* Khai Mei Chin [755332]
22+
*
23+
*/
24+
1325
public class Simulation {
1426

15-
public ArrayList<Station> stations;
16-
public ArrayList<Line> lines;
17-
public ArrayList<Train> trains;
27+
private ArrayList<Station> stations;
28+
private ArrayList<Line> lines;
29+
private ArrayList<Train> trains;
1830

1931
public Simulation(String fileName){
2032
// Create a map reader and read in the file

core/src/com/unimelb/swen30006/metromadness/exceptions/PlatformFullException.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
13+
* Exception if the platform is full and a train tries to enter.
614
*/
715

816
public class PlatformFullException extends Exception {

core/src/com/unimelb/swen30006/metromadness/exceptions/StationNotFoundException.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
613
*/
714

815
public class StationNotFoundException extends Exception{

core/src/com/unimelb/swen30006/metromadness/exceptions/TrackNotFoundException.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
613
*/
714

815
public class TrackNotFoundException extends Exception {

core/src/com/unimelb/swen30006/metromadness/exceptions/TrainCargoFullException.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
613
*/
714

815
public class TrainCargoFullException extends Exception {

core/src/com/unimelb/swen30006/metromadness/exceptions/TrainNotFoundException.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
613
*/
714

815
public class TrainNotFoundException extends Exception{

core/src/com/unimelb/swen30006/metromadness/exceptions/TrainPassengerFullException.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
package com.unimelb.swen30006.metromadness.exceptions;
22

33
/**
4-
* Nate Bhurinat W. (@natebwangsut | nate.bwangsut@gmail.com)
5-
* https://github.com/natebwangsut
4+
* [SWEN30006] Software Modelling and Design
5+
* Semester 1, 2017
6+
* Project Part B - Metro Madness
7+
*
8+
* Group 107:
9+
* Nate Wangsutthitham [755399]
10+
* Kolatat Thangkasemvathana [780631]
11+
* Khai Mei Chin [755332]
12+
*
613
*/
714

815
public class TrainPassengerFullException extends Exception {

core/src/com/unimelb/swen30006/metromadness/passengers/Passenger.java

+42-13
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@
55
import com.unimelb.swen30006.metromadness.stations.CargoStation;
66
import com.unimelb.swen30006.metromadness.stations.Station;
77

8+
/**
9+
* [SWEN30006] Software Modelling and Design
10+
* Semester 1, 2017
11+
* Project Part B - Metro Madness
12+
*
13+
* Group 107:
14+
* Nate Wangsutthitham [755399]
15+
* Kolatat Thangkasemvathana [780631]
16+
* Khai Mei Chin [755332]
17+
*
18+
*/
19+
820
public class Passenger {
921

10-
final public int id;
11-
public Station beginning;
12-
public Station destination;
13-
public float travelTime;
14-
public boolean reachedDestination;
15-
public Cargo cargo;
22+
private final int id;
23+
private Station beginning;
24+
private Station destination;
25+
private float travelTime;
26+
private boolean reachedDestination;
27+
private Cargo cargo;
1628

1729
public Passenger(int id, Random random, Station start, Station end){
1830
this.id = id;
@@ -29,20 +41,27 @@ public Passenger(int id, Random random, Station start, Station end){
2941
}
3042
}
3143

44+
45+
public int getID(){
46+
return this.id;
47+
}
48+
49+
public Station getDestination(){
50+
return this.destination;
51+
}
52+
53+
public float getTravelTime(){
54+
return this.travelTime;
55+
}
56+
3257
public void update(float time){
3358
if(!this.reachedDestination){
3459
this.travelTime += time;
3560
}
3661
}
3762

38-
public Cargo getCargo(){
39-
return cargo;
40-
}
41-
42-
public Cargo generateCargo(Random random){
43-
return new Cargo(random.nextInt(50) +1);
44-
}
4563

64+
// Encapsulated Cargo class and its methods
4665
public class Cargo{
4766
private int weight;
4867

@@ -58,4 +77,14 @@ public void setWeight(int weight) {
5877
this.weight = weight;
5978
}
6079
}
80+
81+
public Cargo generateCargo(Random random){
82+
return new Cargo(random.nextInt(50) +1);
83+
}
84+
85+
public Cargo getCargo(){
86+
return cargo;
87+
}
88+
89+
6190
}

0 commit comments

Comments
 (0)