Advertisement
PhilDrummer

Assignment_4 01

Oct 9th, 2014
3,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 2.07 KB | None | 0 0
  1. note
  2.     description: "Creating new objects for Zurich."
  3.  
  4. class
  5.     OBJECT_CREATION
  6.  
  7. inherit
  8.  
  9.     ZURICH_OBJECTS
  10.  
  11. feature -- Explore Zurich
  12.  
  13.     explore
  14.             -- Create new objects for Zurich.
  15.  
  16.         do
  17.             add_buildings
  18.             add_route
  19.             Zurich_map.update
  20.         end
  21.  
  22.     -- Custom buildings as attributes
  23.  
  24.     eth_main: BUILDING
  25.  
  26.     opera_house: BUILDING
  27.  
  28.     spruengli: BUILDING
  29.  
  30.     add_buildings
  31.             -- Add some buildings
  32.         local
  33.             -- Building vectors as locals
  34.             NW_eth_main: VECTOR
  35.             SE_eth_main: VECTOR
  36.             NW_opera_house: VECTOR
  37.             SE_opera_house: VECTOR
  38.             NW_spruengli: VECTOR
  39.             SE_spruengli: VECTOR
  40.         do
  41.             -- Creating the three buildings
  42.             create NW_eth_main.make (230, -10)
  43.             create SE_eth_main.make (300, -100)
  44.             create eth_main.make ("eth_main", NW_eth_main, SE_eth_main)
  45.             Zurich.add_building (eth_main)
  46.             create NW_opera_house.make (250, -1420)
  47.             create SE_opera_house.make (350, -1480)
  48.             create opera_house.make ("opera_house", NW_opera_house, SE_opera_house)
  49.             Zurich.add_building (opera_house)
  50.             create NW_spruengli.make (-90, -660)
  51.             create SE_spruengli.make (-60, -700)
  52.             create spruengli.make ("spruengli", NW_spruengli, SE_spruengli)
  53.             Zurich.add_building (spruengli)
  54.         end
  55.  
  56.     polyterrasse_paradeplatz_opera: ROUTE -- Custom route as an attribute
  57.  
  58.     add_route
  59.             -- Add a route (Polyterrasse - Paradeplatz - Opernhaus)
  60.         local
  61.             -- The legs as locals
  62.             polyterrasse_central: LEG
  63.             central_paradeplatz: LEG
  64.             paradeplatz_opera: LEG
  65.         do
  66.             -- Creating the custom route
  67.             create polyterrasse_central.make (Zurich.station ("Polyterrasse"), Zurich.station ("Central"), Zurich.line (24))
  68.             create central_paradeplatz.make (Zurich.station ("Central"), Zurich.station ("Paradeplatz"), Zurich.line (6))
  69.             create paradeplatz_opera.make (Zurich.station ("Paradeplatz"), Zurich.station ("Opernhaus"), Zurich.line (2))
  70.             polyterrasse_central.link (central_paradeplatz)
  71.             central_paradeplatz.link (paradeplatz_opera)
  72.             create polyterrasse_paradeplatz_opera.make (polyterrasse_central)
  73.             Zurich.add_route (polyterrasse_paradeplatz_opera)
  74.         end
  75.  
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement