Class TrainGenerator

java.lang.Object
  extended by TrainGenerator

public class TrainGenerator
extends java.lang.Object

This class provide methods for generating a Train. COMPLETE THIS CLASS and HAND IN THIS FILE

See Also:
Config

Constructor Summary
TrainGenerator()
           
 
Method Summary
static Train getIncomingTrain()
          Get a new train generated randomly.
static Train getIncomingTrainFromFile(java.lang.String filename)
          Get a new train generated from a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrainGenerator

public TrainGenerator()
Method Detail

getIncomingTrain

public static Train getIncomingTrain()
Get a new train generated randomly. The constant variables for determining how many cargo, what cargo and how heavy are in Config.

Returns:
a train generated randomly

getIncomingTrainFromFile

public static Train getIncomingTrainFromFile(java.lang.String filename)
Get a new train generated from a file. Files for generating a train must have the format as follow

{destination},{cargo},{weight}
{destination},{cargo},{weight}
...

where {destination} is a string among Config.DEST_ARRAY, {cargo} is a string among Config.CARGO_ARRAY, and {weight} is a string for any positive integer.

Ignore the line if it is not matched in this format. See the sample in/outputs provided in the assignment description to get more details.

Parameters:
filename - train input file name
Returns:
a train generated from a file