Guest User

Untitled

a guest
Aug 28th, 2020
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.70 KB | None | 0 0
  1. class Planet
  2.     attr_reader :list_marker
  3.    
  4.     @@list_marker = []
  5.    
  6.     def initialize(name_planet)
  7.         @name_planet = name_planet
  8.         @list_marker = []
  9.     end
  10.  
  11.     def list_marker
  12.         @@list_marker
  13.     end
  14.  
  15.     def find_sys(place)
  16.  
  17.         if place.location == @name_planet
  18.             @@list_marker << place
  19.  
  20.             puts "our system"
  21.         else
  22.             puts "not our system"
  23.         end
  24.     end
  25.  
  26. end
  27.  
  28.  
  29. class Map
  30.     attr_accessor :location
  31.  
  32.     def initialize
  33.  
  34.         @long = 66
  35.         @width = 33
  36.         @location = 'moon'
  37.     end
  38.  
  39. end
  40.  
  41. planet = Planet.new('moon')
  42.  
  43. global_map = Map.new
  44. big_map = Map.new
  45. little_map = Map.new
  46.  
  47. planet.find_sys(global_map)
  48. planet.find_sys(big_map)
  49. planet.find_sys(little_map)
  50.  
  51. p planet.list_marker.map(&:location)
Advertisement
Add Comment
Please, Sign In to add comment