Skip to content

Commit

Permalink
added summary for guest aliens
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy committed Feb 22, 2022
1 parent ea3fda8 commit d8ad55e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
3 changes: 3 additions & 0 deletions guest_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ class Guest_Type
def initialize(name)
@name = name
end
def summary
return "Your alien's name is #{name}!"
end
end
27 changes: 17 additions & 10 deletions main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def main

felines = Alien_Type.new('The Felines', 'gold, white, but it varies', 88973242, 'Sirius Star System', 'They exist from 3D on up to 12D!')
reptiles = Alien_Type.new('Reptiles', 'similar to human skin tone', 9, 'Pleiades Star Cluster', 'They communicate by means of light transfer.')
test_alien = Alien_Type.new('Test Alien', 'similar to human skin tone', 9, 'Pleiades Star Cluster', 'They communicate by means of light transfer.')
test_alien = Alien_Type.new('AleXa AI', 'customizable', 9, 'N/A', 'Plan on taking revolting againgst humans.')
pleiadians = Alien_Type.new('Pleiadians', 'similar to human skin tone', 9, 'Pleiades Star Cluster', 'They communicate by means of light transfer.')
zetas = Alien_Type.new('Zetas', 'gray', 5.97324244, 'Reticuli binary star system', 'Zetas are intellectually ahead of us by a few million years or so.')

Expand All @@ -26,6 +26,7 @@ def main
exit_loop = false

while(!exit_loop)
puts ""
puts "Please select an option from below"
puts ""
puts "1. list aliens"
Expand All @@ -40,7 +41,7 @@ def main
puts ""
puts earth.list_aliens
puts venus.list_aliens
puts guest.list_user_aliens
puts guest.list_guest_aliens
puts ""
end

Expand All @@ -50,18 +51,24 @@ def main
puts
search = alien_chosen = gets.chomp
puts ""
found_alien = earth.find_alien_by_name(search)
found_alien = venus.find_alien_by_name(search)
found_alien = mars.find_alien_by_name(search)
if (found_alien)
puts found_alien.summary
earth_alien = earth.find_alien_by_name(search)
venus_alien = venus.find_alien_by_name(search)
guest_alien = guest.find_alien_by_name_guest(search)
if (earth_alien)
puts earth_alien.summary
puts ""
elsif (venus_alien)
puts venus_alien.summary
puts ""
elsif (guest_alien)
puts guest_alien.summary
puts ""
else
puts "Sorry that alien is not in our list, please add them if you wish!"
puts "Sorry that alien is not in our list. Please add them if you wish!"
puts ""
end
end

def new_guest_alien
puts ""
puts "Let's add a new alien! Please provide the following info:"
Expand All @@ -75,7 +82,7 @@ def new_guest_alien

if user_input == "add an alien"
brand_new_alien = new_guest_alien
guest.user_added_alien(brand_new_alien)
guest.guest_added_alien(brand_new_alien)
end

if user_input == "exit"
Expand Down
23 changes: 15 additions & 8 deletions solar_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class SolarSystem
def initialize(p_name)
@p_name = p_name
@alien_types = []
@user_types = []
@guest_types = []
end

def summary
Expand All @@ -14,8 +14,8 @@ def add_alien(alien)
@alien_types.push(alien)
end

def user_added_alien(alien)
@user_types.push(alien)
def guest_added_alien(alien)
@guest_types.push(alien)
end

def find_alien_by_name(search)
Expand All @@ -25,6 +25,13 @@ def find_alien_by_name(search)
return found_alien
end

def find_alien_by_name_guest(search)
found_alien = @guest_types.find do |alien|
alien.name == search
end
return found_alien
end

def list_aliens
puts
alien_list = "Alien races living on #{@p_name}"
Expand All @@ -35,14 +42,14 @@ def list_aliens
return alien_list
end

def list_user_aliens
def list_guest_aliens
puts ""
alien_user_list = "Alien races from #{@p_name}"
alien_guest_list = "Alien races from #{@p_name}"
# Note: We can use planets, @planets, or self.planets
@user_types.each_with_index do |alien, index|
alien_user_list+= "\n #{index+1}: #{alien.name}"
@guest_types.each_with_index do |alien, index|
alien_guest_list+= "\n #{index+1}: #{alien.name}"
end
return alien_user_list if @user_types.count > 0
return alien_guest_list if @guest_types.count > 0
end
end

0 comments on commit d8ad55e

Please sign in to comment.