- Timestamp:
- 10/10/2017 04:35:30 PM (9 years ago)
- Location:
- trunk/src/atmsdriver
- Files:
-
- 3 edited
-
NetworkLoader.java (modified) (2 diffs)
-
model/Highways.java (modified) (1 diff)
-
model/Station.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/NetworkLoader.java
r84 r90 228 228 sc.nextInt(); // skip count 229 229 sc.nextInt(); // fwy 230 DIRECTION dir = DIRECTION. getEnum(sc.next()); // direction230 DIRECTION dir = DIRECTION.toDirection(sc.next()); // direction 231 231 sc.nextDouble(); 232 232 … … 261 261 scLine.nextInt(); // skip count 262 262 int fwy = scLine.nextInt(); // fwy 263 DIRECTION dir = DIRECTION. getEnum(scLine.next()); // direction263 DIRECTION dir = DIRECTION.toDirection(scLine.next()); // direction 264 264 double postmile = scLine.nextDouble(); 265 265 String ldsName = getLocation(strLine); /************* DOESNT GRAB WHOLE???? *///// -
trunk/src/atmsdriver/model/Highways.java
r89 r90 102 102 DIRECTION hwyDir = hwyKey.get(hwyNum); 103 103 Collections.sort(highwayTable.get(hwyKey)); 104 System.out.println("Adding highway: " + hwyNum + " " + hwyDir. name);104 System.out.println("Adding highway: " + hwyNum + " " + hwyDir.toString().charAt(0)); 105 105 highways.add(new Highway(hwyNum, 106 106 hwyDir, hwyStations)); -
trunk/src/atmsdriver/model/Station.java
r88 r90 25 25 final private String location; 26 26 final private List<LoopDetector> loops; 27 final private int freeway;27 final private int highwayNum; 28 28 final private double postmile; 29 29 final private DIRECTION direction; … … 35 35 /* Constructor */ 36 36 public Station(int lineNum, int ldsID, int drop, 37 String location, List<LoopDetector> loops, int fwy,37 String location, List<LoopDetector> loops, int hwy, 38 38 DIRECTION direction, double postmile) { 39 39 this.lineNum = lineNum; … … 44 44 this.postmile = postmile; 45 45 this.direction = direction; 46 this. freeway = fwy;46 this.highwayNum = hwy; 47 47 48 48 this.MLTotVol = 0; … … 52 52 public int getHighwayNumber() 53 53 { 54 return this. freeway;54 return this.highwayNum; 55 55 } 56 56 … … 73 73 build.append(Integer.toString(this.drop)); 74 74 build.append(" "); 75 build.append(Integer.toString(this. freeway));76 build.append(" "); 77 build.append(this.direction. name);75 build.append(Integer.toString(this.highwayNum)); 76 build.append(" "); 77 build.append(this.direction.getLetter()); 78 78 build.append(" "); 79 79 build.append(Double.toString(this.postmile)); … … 93 93 } 94 94 95 /** Compare this Station to another by postmile. 96 * Note: This might be better as a Comparator since it checks only one field. 97 */ 95 98 @Override 96 99 public int compareTo(Object otherStation) { 100 // check for identity 101 if (this == otherStation) return 0; 97 102 // check that Object is of type Station, if not throw exception 98 103 if (!(otherStation instanceof Station)) { … … 163 168 164 169 Element directionElement = theDoc.createElement(XML_TAGS.DIRECTION.tag); 165 directionElement.appendChild(theDoc.createTextNode( this.direction.name));170 directionElement.appendChild(theDoc.createTextNode(""+this.direction.getLetter())); 166 171 stationElement.appendChild(directionElement); 167 172 168 173 Element freewayElement = theDoc.createElement(XML_TAGS.FREEWAY.tag); 169 freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this. freeway)));174 freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.highwayNum))); 170 175 stationElement.appendChild(freewayElement); 171 176 … … 194 199 public static enum DIRECTION { 195 200 196 NORTH("N"), 197 SOUTH("S"), 198 EAST("E"), 199 WEST("W"); 200 201 String name; 202 203 DIRECTION(String name) { 204 this.name = name; 205 } 206 201 NORTH, 202 SOUTH, 203 EAST, 204 WEST; 205 206 // All the first letters of the values, in order. 207 private static String allLetters = "NSEW"; 208 209 /** Return the first letter of this enum. 210 * 211 * @return String first letter of this enum. 212 */ 213 public String getLetter() 214 { 215 return this.toString().substring(0,1); 216 } 217 207 218 /** 208 * Returns the direction enum, given a string value.219 * Returns a direction given its first character. 209 220 * 210 * @param name str value for enum 211 * @return enum for given str value 221 * @param letter the first character of a direction 222 * @return direction corresponding to letter 223 * @pre letter must be one of allLetters 212 224 */ 213 public static DIRECTION getEnum(String name) { 214 switch (name) { 215 case "S": 216 return SOUTH; 217 case "N": 218 return NORTH; 219 case "E": 220 return EAST; 221 case "W": 222 return WEST; 223 default: 224 return null; 225 } 226 } 225 public static DIRECTION toDirection(String letter) 226 { 227 return values()[allLetters.indexOf(letter.charAt(0))]; 228 } 229 227 230 } 228 231 }
Note: See TracChangeset
for help on using the changeset viewer.
