Advertisement
PhilDrummer

Assignment_8 02 SHORT_TRIPS.e

Nov 23rd, 2014
3,224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 2.53 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.             -- WHY: Why is it not printing..
  18.             console.output ("Calculating...!")
  19.             ---------------------------------
  20.  
  21.             highlight_reachable (s, 120)
  22.             console.output ("Done!")
  23.         end
  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.         do
  32.             -- WHY: Why is it not printing..
  33.             console.output ("Calculating...! Please be patient.")
  34.             --------------------------------
  35.  
  36.             across
  37.                 s.lines as i
  38.             loop
  39.                     -- Highlight the current station
  40.                 if
  41.                     not zurich_map.station_view (s).is_highlighted
  42.                 then
  43.                     zurich_map.station_view (s).highlight
  44.                 end
  45.  
  46.                     -- Go through the cases
  47.                 if
  48.                     i.item.north_terminal /= void and then i.item.next_station (s, i.item.north_terminal) /= void and then (i.item.distance (s, i.item.next_station (s, i.item.north_terminal)) / i.item.speed) <= t
  49.                 then
  50.                     highlight_reachable (i.item.next_station (s, i.item.north_terminal), t - (i.item.distance (s, i.item.next_station (s, i.item.north_terminal)) / i.item.speed))
  51.                 end
  52.                 if
  53.                     i.item.east_terminal /= void and then i.item.next_station (s, i.item.east_terminal) /= void and then (i.item.distance (s, i.item.next_station (s, i.item.east_terminal)) / i.item.speed) <= t
  54.                 then
  55.                     highlight_reachable (i.item.next_station (s, i.item.east_terminal), t - (i.item.distance (s, i.item.next_station (s, i.item.east_terminal)) / i.item.speed))
  56.                 end
  57.                 if
  58.                     i.item.south_terminal /= void and then i.item.next_station (s, i.item.south_terminal) /= void and then (i.item.distance (s, i.item.next_station (s, i.item.south_terminal)) / i.item.speed) <= t
  59.                 then
  60.                     highlight_reachable (i.item.next_station (s, i.item.south_terminal), t - (i.item.distance (s, i.item.next_station (s, i.item.south_terminal)) / i.item.speed))
  61.                 end
  62.                 if
  63.                     i.item.west_terminal /= void and then i.item.next_station (s, i.item.west_terminal) /= void and then (i.item.distance (s, i.item.next_station (s, i.item.west_terminal)) / i.item.speed) <= t
  64.                 then
  65.                     highlight_reachable (i.item.next_station (s, i.item.west_terminal), t - (i.item.distance (s, i.item.next_station (s, i.item.west_terminal)) / i.item.speed))
  66.                 end
  67.             end
  68.         end
  69.  
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement