Advertisement
PhilDrummer

Assignment_9 02 SHORT_TRIPS.e

Nov 29th, 2014
2,845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.25 KB | None | 0 0
  1. note
  2.     description: "Short trips."
  3.  
  4. class
  5.     SHORT_TRIPS
  6.  
  7. inherit
  8.     ZURICH_OBJECTS
  9.  
  10. feature -- Explore Zurich
  11.  
  12.     highlight_short_distance (s: STATION)
  13.             -- Highlight stations reachable from `s' within 2 minutes.
  14.         require
  15.             station_exists: s /= Void
  16.         do
  17.             create checked_stations
  18.             highlight_reachable (s, 120)
  19.         end
  20.  
  21. feature -- Access
  22.  
  23.     checked_stations: V_LINKED_STACK [STATION]
  24.  
  25. feature {NONE} -- Implementation
  26.  
  27.     highlight_reachable (s: STATION; t: REAL_64)
  28.             -- Highight stations reachable from `s' within `t' seconds.
  29.         require
  30.             station_exists: s /= Void
  31.         local
  32.             line: LINE
  33.             next: STATION
  34.         do
  35.             if t >= 0.0 then
  36.                 Zurich_map.station_view (s).highlight
  37.                 checked_stations.extend (s)
  38.                 across
  39.                     s.lines as li
  40.                 loop
  41.                     line := li.item
  42.                     next := line.next_station (s, line.north_terminal)
  43.                     if next /= Void and then not checked_stations.has (next) then
  44.                         highlight_reachable (next, t - s.position.distance (next.position) / line.speed)
  45.                     end
  46.                     next := line.next_station (s, line.south_terminal)
  47.                     if next /= Void and then not checked_stations.has (next) then
  48.                         highlight_reachable (next, t - s.position.distance (next.position) / line.speed)
  49.                     end
  50.                 end
  51.             end
  52.         end
  53.  
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement