From f485633348eb91cbada14c2798b8abf6ae546e27 Mon Sep 17 00:00:00 2001 From: VirtualLindsey Date: Wed, 16 Aug 2017 09:00:41 -0700 Subject: [PATCH 1/2] Create Pipes - Lindsey - Solar_System --- Pipes - Lindsey - Solar_System | 85 ++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Pipes - Lindsey - Solar_System diff --git a/Pipes - Lindsey - Solar_System b/Pipes - Lindsey - Solar_System new file mode 100644 index 00000000..015a2643 --- /dev/null +++ b/Pipes - Lindsey - Solar_System @@ -0,0 +1,85 @@ +class SolarSystem + def initialize(p) + @planet = p + end + + def add_planet(new_planet) + @planet << new_planet + end + + def return_print + return_string = "" + counter = 1 + + @planet.each do |current_planet| + return_string += "#{counter}. " + current_planet.planet_name + "\n" + counter += 1 + end + return return_string + end +end + +class Planet + attr_reader :planet_name, :planet_size, :planet_day_cycle, + :planet_appearance, :planet_livable + def initialize(name, size, cycle, appearance, livable) + @planet_name = name + @planet_size = size + @planet_day_cycle = cycle + @planet_appearance = appearance + @planet_livable = livable + end +end + +earth = Planet.new('Earth', 'big', 24, 3, true) +mercury = Planet.new('Mercury', 'small', 1407, 1, false) +uranus = Planet.new('Uranus', 'very big', 17, 7, false) + +test = SolarSystem.new([earth, mercury, uranus]) +puts test.return_print + +def return_attribute + return "Size:\t#{@size}\nColour:\t#{@colour}\nDayCycle:\t#{@day_cycle}\nNumber of Moons: #{@moons}" + end +end + + +=begin + +Irene helped me with this section. It's not finished, and it probably doesn't run. + +all_planets = [earth, mercury, uranus] + +solar_system = SolarSystem.new(all_planets) + +puts "====See all the planets in this fake Solar System!====" +puts solar_system.display + +puts "\nWhich planet do you want to investigate?" +planet_choice = gets.chomp.capitalize +until planet_choice == "Earth" || planet_choice == "Mercury" || planet_choice == "Uranus" + puts "Enter something I can work with!" + planet_choice = gets.chomp.capitalize +end + +puts solar_system.print_planet_att(planet_choice) + + +puts "\nWant to add another planet to this Solar System? Enter 'yes' or 'no' now!" + +user_input = gets.chomp.upcase +if user_input == "yes" + + planet_now_made = solar_system.create_planet + + solar_system.add_planet(planet_now_made) + + puts "=== Summary of Your Solar System ===" + puts + + solar_system.print_all +else + puts "Come back another time!" +end + +=end From 3d868d3ded82b39991845d605ef4d6f527e5b05d Mon Sep 17 00:00:00 2001 From: VirtualLindsey Date: Tue, 22 Aug 2017 09:07:32 -0700 Subject: [PATCH 2/2] Update Pipes - Lindsey - Solar_System --- Pipes - Lindsey - Solar_System | 41 ---------------------------------- 1 file changed, 41 deletions(-) diff --git a/Pipes - Lindsey - Solar_System b/Pipes - Lindsey - Solar_System index 015a2643..ecd6fd4b 100644 --- a/Pipes - Lindsey - Solar_System +++ b/Pipes - Lindsey - Solar_System @@ -42,44 +42,3 @@ def return_attribute return "Size:\t#{@size}\nColour:\t#{@colour}\nDayCycle:\t#{@day_cycle}\nNumber of Moons: #{@moons}" end end - - -=begin - -Irene helped me with this section. It's not finished, and it probably doesn't run. - -all_planets = [earth, mercury, uranus] - -solar_system = SolarSystem.new(all_planets) - -puts "====See all the planets in this fake Solar System!====" -puts solar_system.display - -puts "\nWhich planet do you want to investigate?" -planet_choice = gets.chomp.capitalize -until planet_choice == "Earth" || planet_choice == "Mercury" || planet_choice == "Uranus" - puts "Enter something I can work with!" - planet_choice = gets.chomp.capitalize -end - -puts solar_system.print_planet_att(planet_choice) - - -puts "\nWant to add another planet to this Solar System? Enter 'yes' or 'no' now!" - -user_input = gets.chomp.upcase -if user_input == "yes" - - planet_now_made = solar_system.create_planet - - solar_system.add_planet(planet_now_made) - - puts "=== Summary of Your Solar System ===" - puts - - solar_system.print_all -else - puts "Come back another time!" -end - -=end