Created
March 8, 2012 03:05
-
-
Save mattiasarro/1998309 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port = new Airport(1); | |
port = new Airport("/custom/path.xml"); | |
port.save(); | |
port.save("/custom/path.xml") | |
private XMLHandler handler; | |
public Airport() { | |
this(240, 50, 300, "Heathrow"); | |
handler = new XMLHandler(); | |
} | |
// load from XML/airport_ID.xml | |
public Airport(int airportId) { | |
handler = new XMLHandler(airportId); | |
handler.initializeAirport(this); | |
} | |
// could point to a user-specified location | |
public Airport(String xmlLocation) { | |
handler = new XMLHandler(xmlLocation); | |
handler.initializeAirport(this); | |
} | |
// When initialized from airportID or xmlLocation, save back to the same file. | |
// Otherwise save to the next free XML/airport_ID.xml | |
public void saveXML() { | |
if (handler == null) { | |
handler = new XMLHandler(); | |
} | |
handler.saveAirport(this); | |
} | |
// No matter how it was initialized, save to xmlLocation. | |
public void saveXML(String xmlLocation) { | |
handler.saveAirport(this, xmlLocation); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment