Advertisement
PhilDrummer

Assignment_7 02 GHOST_INVASION.e

Nov 19th, 2014
2,784
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.09 KB | None | 0 0
  1. note
  2.     description: "Adding ghosts to Zurich."
  3.  
  4. class
  5.     GHOST_INVASION
  6.  
  7. inherit
  8.     ZURICH_OBJECTS
  9.  
  10. feature -- Explore Zurich
  11.  
  12.     invade
  13.             -- Add ghosts to random stations.
  14.         local
  15.             random: V_RANDOM
  16.             radius: REAL_64
  17.             i, cpos: INTEGER
  18.             station: STATION
  19.         do
  20.             create random
  21.             from
  22.                 i := 1
  23.             until
  24.                 i > 10
  25.             loop
  26.                 radius := random.bounded_item (10, 100).to_double
  27.                 random.forth
  28.                 cpos := random.bounded_item (1, Zurich.stations.count)
  29.                 random.forth
  30.                 across
  31.                     zurich.stations as c
  32.                 loop
  33.                     c.go_to (cpos)
  34.                     station := c.item
  35.                     c.finish
  36.                 end
  37.                 add_ghost (station, radius)
  38.                 i := i + 1
  39.             end
  40.         end
  41.  
  42.     add_ghost (a_station: STATION; a_radius: REAL_64)
  43.             -- Add a ghost going around `a_station'.
  44.         require
  45.             a_station_exists: a_station /= Void
  46.             a_radius_positive: a_radius > 0.0
  47.         local
  48.             ghost: GHOST
  49.         do
  50.             create ghost.make (a_station, a_radius)
  51.             Zurich.add_custom_mobile (ghost)
  52.             Zurich_map.update_mobile
  53.             Zurich_map.update
  54.             Zurich_map.custom_mobile_view (ghost).set_icon ("..\image\ghost.png")
  55.         end
  56.  
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement