Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sockets - Nara #27

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated Wave 2 methods
bonara committed Feb 26, 2019
commit 51d144bcd1c8fbc375c85d5d1382f31707021409
22 changes: 17 additions & 5 deletions main.rb
Original file line number Diff line number Diff line change
@@ -6,13 +6,25 @@ def main
solar_system.add_planet(earth)
mars = Planet.new('Mars', "red", 6.39e23, 2.279e8,'Mars is named after a mythological figure - the Roman god of war')
solar_system.add_planet(mars)
list = solar_system.list_planets
puts list
venus = Planet.new('Venus', "yellow-white", 4.867e24, 1.082e8,'Venus is the second brightest natural object in the sky')
solar_system.add_planet(venus)
# list = solar_system.list_planets
# puts list

found_planet = solar_system.find_planet_by_name('Earth')
found_planet = solar_system.find_planet_by_name('Venuss')
puts found_planet
puts found_planet.summary
puts found_planet.summary if found_planet.is_a? Planet

end
while true
puts "What would you like to do next? You can list planets or exit."
user_input = gets.chomp.downcase
if user_input == "exit"
return
elsif user_input == "list planets"
list = solar_system.list_planets
puts list
end
end

end
main
7 changes: 7 additions & 0 deletions solar_system.rb
Original file line number Diff line number Diff line change
@@ -19,11 +19,18 @@ def list_planets
end

def find_planet_by_name(name)
found = false
@planets.each do |planet|
if planet.name.downcase == name.downcase
found = true
return planet
else
found = false
end
end
if found == false
return "This is not a planet!"
end
end
end