Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change toString() abstraction

  • Loading branch information...
commit 77725561ee160392292adda478ccc729f23b8b01 1 parent 48d240d
@edma2 authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/ma/eugene/nextbus/NextBus.java
View
13 src/ma/eugene/nextbus/NextBus.java
@@ -36,11 +36,12 @@ public NextBus(String agency) throws IOException, SAXException {
}
/**
- * A set of lines, where each line contains a BusStop.
+ * Get string representations of all my BusStops.
+ * Each BusStop is separated by a newline.
*
- * @return the representation of this NextBus instance as a String.
+ * @return all BusStops as a single String.
*/
- public String toString() {
+ private String stringifyStops() {
StringBuilder sb = new StringBuilder();
for (BusStop bs : stops.values())
sb.append(bs + "\n");
@@ -55,7 +56,7 @@ public String toString() {
* @param pathToDump the path where the dump file should be written
*/
public void saveStops(String pathToDump) throws IOException {
- writeToFile(new File(pathToDump), toString());
+ writeToFile(new File(pathToDump), stringifyStops());
}
/**
@@ -142,4 +143,8 @@ private String readFromFile(File file) throws IOException {
}
return sb.toString();
}
+
+ public String toString() {
+ return stringifyStops();
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.