From cca13342ba5568b891001a00324b1943637add2c Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Mon, 25 Feb 2019 16:46:04 -0800 Subject: [PATCH 1/6] wave 1 done. --- planet.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 planet.rb diff --git a/planet.rb b/planet.rb new file mode 100644 index 00000000..d936e072 --- /dev/null +++ b/planet.rb @@ -0,0 +1,16 @@ +class Planet +attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact + + def initialize (name, color, mass_kg, distance_from_sun_km) + @name = name + @color = color + @mass_kg = mass_kg + @distance_from_sun_km = distance_from_sun_km + @fun_fact = fun_fact + end + + def summary + return "The planet of #{name} is the color #{color} and weighs #{mass_kg} in kg. You might also find it intereesting that it is #{distance_from_sun_km} km away from Earth. The best part of planet #{name} is that it is #{fun_fact}." + end +end + From 85516e5def2d2582f3cd3f41d9cab34bc1610b64 Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Tue, 26 Feb 2019 12:50:12 -0800 Subject: [PATCH 2/6] wv 2- step one complete --- solar_system.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 solar_system.rb diff --git a/solar_system.rb b/solar_system.rb new file mode 100644 index 00000000..8de74551 --- /dev/null +++ b/solar_system.rb @@ -0,0 +1,7 @@ +class SolarSystem + attr_reader :star_name :planets + + def intialize(star_name) + @star_name = star_name + @planets = planets + From 3850e0e7c1cc2e47ce857d9391ba237b7739b898 Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Tue, 26 Feb 2019 13:26:34 -0800 Subject: [PATCH 3/6] waves 1 and 2 done for reallll --- main.rb | 18 ++++++++++++++++++ planet.rb | 3 +-- solar_system.rb | 23 +++++++++++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 main.rb diff --git a/main.rb b/main.rb new file mode 100644 index 00000000..360f3aa1 --- /dev/null +++ b/main.rb @@ -0,0 +1,18 @@ +require_relative "planet.rb" +require_relative "solar_system" + +def main + earth = Planet.new("Earth", "blue-green", 5.972e24, 1.496e8, "Only planet known to support life") + astra = Planet.new("Cloudster", "pink", 5, 23, "Hello Kitty Universe planet") + ego = Planet.new("Puffy", "periwinkle", 124234, 325623, "Hello Kitte bioverse") + namek = Planet.new("Glitterish", "Surruliean", 35435472, 23513541, "Hello Kitty world with lots of water and grass") + # Solar System # 1 + solar_system = SolarSystem.new("Ethereal") + solar_system.add_planet(earth) + solar_system.add_planet(astra) + list = solar_system.list_planets + found_planet = solar_system.find_planet_by_name("Earth") + puts found_planet + puts found_planet.summary +end +main \ No newline at end of file diff --git a/planet.rb b/planet.rb index d936e072..cafa9152 100644 --- a/planet.rb +++ b/planet.rb @@ -1,7 +1,7 @@ class Planet attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact - def initialize (name, color, mass_kg, distance_from_sun_km) + def initialize(name, color, mass_kg, distance_from_sun_km) @name = name @color = color @mass_kg = mass_kg @@ -13,4 +13,3 @@ def summary return "The planet of #{name} is the color #{color} and weighs #{mass_kg} in kg. You might also find it intereesting that it is #{distance_from_sun_km} km away from Earth. The best part of planet #{name} is that it is #{fun_fact}." end end - diff --git a/solar_system.rb b/solar_system.rb index 8de74551..cb0e279a 100644 --- a/solar_system.rb +++ b/solar_system.rb @@ -3,5 +3,24 @@ class SolarSystem def intialize(star_name) @star_name = star_name - @planets = planets - + @planets = [] + end + + def add_planets(planet) + @planets << planet + end + + def list_planets + list = @planets.each_with_index.map do |planet, i| + "#{i +1}. #{planet.name}." + end + return "Planets orbiting #{@star_name}: \n#{list.join("\n")}" + end + + def find_planet_by_name(planet_name) + return @planets.find do |planet| + planet.name == planet_name.capitalize + end + end +end + From 6f9ee611683cadba411e2e2c193085cac987685a Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Tue, 26 Feb 2019 13:40:20 -0800 Subject: [PATCH 4/6] wave 3 step 1 done --- main.rb | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/main.rb b/main.rb index 360f3aa1..b4db80b0 100644 --- a/main.rb +++ b/main.rb @@ -3,16 +3,32 @@ def main earth = Planet.new("Earth", "blue-green", 5.972e24, 1.496e8, "Only planet known to support life") - astra = Planet.new("Cloudster", "pink", 5, 23, "Hello Kitty Universe planet") - ego = Planet.new("Puffy", "periwinkle", 124234, 325623, "Hello Kitte bioverse") - namek = Planet.new("Glitterish", "Surruliean", 35435472, 23513541, "Hello Kitty world with lots of water and grass") - # Solar System # 1 + cloudster = Planet.new("Cloudster", "pink", 5, 23, "Hello Kitty Universe planet") + puffy = Planet.new("Puffy", "periwinkle", 124234, 325623, "Hello Kitte bioverse") + glitterish = Planet.new("Glitterish", "Surruliean", 35435472, 23513541, "Hello Kitty world with lots of water and grass") + + # Solar System 1 solar_system = SolarSystem.new("Ethereal") solar_system.add_planet(earth) - solar_system.add_planet(astra) + solar_system.add_planet(cloudster) list = solar_system.list_planets + + # Solar System 2 + two_solar_system_ = SolarSystem.new("Isometric") + two_solar_system.add_planet(puffy) + two_solar_system.add_planet(glitterish) + two_list = two_solar_system.list_planets + +# Control Loop +puts "What would you like to do next? You can choose from: $\ List planets $\ Exit" +answer = gets.chomp + + + + found_planet = solar_system.find_planet_by_name("Earth") puts found_planet puts found_planet.summary end -main \ No newline at end of file +main + From 4a7ca60eabbfffcd75d714e30dbce64efdfb6ca3 Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Tue, 26 Feb 2019 18:49:10 -0800 Subject: [PATCH 5/6] ugggh done --- main.rb | 78 ++++++++++++++++++++++++++++++++++--------------- planet.rb | 4 +-- solar_system.rb | 24 +++++++++++++-- 3 files changed, 78 insertions(+), 28 deletions(-) diff --git a/main.rb b/main.rb index b4db80b0..7ea94f3d 100644 --- a/main.rb +++ b/main.rb @@ -1,34 +1,66 @@ require_relative "planet.rb" -require_relative "solar_system" +require_relative "solar_system.rb" + +def main_menu + puts "Welcome to make yo own planet!" + puts "What would you like to do next? You can choose from: \n 1. List Planets \n 2. Planet Details \n 3. Add Planet \n 4. Exit" + main +end def main - earth = Planet.new("Earth", "blue-green", 5.972e24, 1.496e8, "Only planet known to support life") + earth = Planet.new("Earth", "blue-green", 5.972e24, 1.496e8, "Only planet known to support life") cloudster = Planet.new("Cloudster", "pink", 5, 23, "Hello Kitty Universe planet") puffy = Planet.new("Puffy", "periwinkle", 124234, 325623, "Hello Kitte bioverse") - glitterish = Planet.new("Glitterish", "Surruliean", 35435472, 23513541, "Hello Kitty world with lots of water and grass") - - # Solar System 1 - solar_system = SolarSystem.new("Ethereal") - solar_system.add_planet(earth) - solar_system.add_planet(cloudster) - list = solar_system.list_planets + glitterish = Planet.new("Glitterish", "surruliean", 35435472, 23513541, "Hello Kitty world with lots of water and grass") - # Solar System 2 - two_solar_system_ = SolarSystem.new("Isometric") - two_solar_system.add_planet(puffy) - two_solar_system.add_planet(glitterish) - two_list = two_solar_system.list_planets + # Solar System 1 + solar_system = SolarSystem.new("Ethereal") + solar_system.add_planets(earth) + solar_system.add_planets(cloudster) + list = solar_system.list_planets -# Control Loop -puts "What would you like to do next? You can choose from: $\ List planets $\ Exit" -answer = gets.chomp + # solar_system = SolarSystem.new("Ethereal") + # solar_system.add_planet(earth) + # solar_system.add_planet(cloudster) + # solar_system.add_planet(puffy) + # solar_system.add_planet(glitterish) + user_input = "y" + while user_input == "y" + puts $\ + puts "Make a selection" + choice = gets.chomp.to_i + list = solar_system.list_planets - - found_planet = solar_system.find_planet_by_name("Earth") - puts found_planet - puts found_planet.summary + if choice == 1 + print list + elsif choice == 2 + puts "Lets find out more about the planets" + print list + planet_info = gets.chomp + found_planet = solar_system.find_planet_by_name(planet_info) + + if found_planet + puts "You have chosen #{found_planet.name}." + puts found_planet.summary + end + + elsif choice == 3 + solar_system.create_planet + elsif choice == 4 + answer = "y" + while answer == "y" + puts "Do you want to play again? Yes or No?" + answer = gets.chomp + if answer == "yes" + main_menu + else + break + end + end + exit + end + end end -main - +main_menu \ No newline at end of file diff --git a/planet.rb b/planet.rb index cafa9152..030e1470 100644 --- a/planet.rb +++ b/planet.rb @@ -1,7 +1,7 @@ class Planet attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact - def initialize(name, color, mass_kg, distance_from_sun_km) + def initialize(name, color, mass_kg, distance_from_sun_km, fun_fact) @name = name @color = color @mass_kg = mass_kg @@ -11,5 +11,5 @@ def initialize(name, color, mass_kg, distance_from_sun_km) def summary return "The planet of #{name} is the color #{color} and weighs #{mass_kg} in kg. You might also find it intereesting that it is #{distance_from_sun_km} km away from Earth. The best part of planet #{name} is that it is #{fun_fact}." - end + end end diff --git a/solar_system.rb b/solar_system.rb index cb0e279a..fb239980 100644 --- a/solar_system.rb +++ b/solar_system.rb @@ -1,7 +1,7 @@ class SolarSystem - attr_reader :star_name :planets + attr_reader :star_name, :planets - def intialize(star_name) + def initialize(star_name) @star_name = star_name @planets = [] end @@ -22,5 +22,23 @@ def find_planet_by_name(planet_name) planet.name == planet_name.capitalize end end -end + + def create_planet + puts "To make a new planet, enter planet details" + puts "enter the name" + new_name = gets.chomp + puts "what color is the planet?" + new_color_planet = gets.chomp + puts "whats the mass in kg" + new_mass_kg = gets.chomp.to_f + puts "what is the distance from the sun" + new_distance_from_sun = gets.chomp.to_i + puts "tell me your planets fun fact" + new_fun_fact = gets.chomp + user_planet = Planet.new(new_name, new_color_planet,new_mass_kg, new_distance_from_sun, new_fun_fact) + add_planets(user_planet) + end + + +end \ No newline at end of file From d53e4b6676cf8195ade2d4b75444044cb071edb2 Mon Sep 17 00:00:00 2001 From: Cloudy Lopez Date: Thu, 28 Feb 2019 15:06:12 -0800 Subject: [PATCH 6/6] workkk. --- main.rb | 4 +++- planet.rb | 1 + solar_system.rb | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/main.rb b/main.rb index 7ea94f3d..78617f79 100644 --- a/main.rb +++ b/main.rb @@ -63,4 +63,6 @@ def main end end end -main_menu \ No newline at end of file +main_menu + +#push! \ No newline at end of file diff --git a/planet.rb b/planet.rb index 030e1470..f34b0f4e 100644 --- a/planet.rb +++ b/planet.rb @@ -13,3 +13,4 @@ def summary return "The planet of #{name} is the color #{color} and weighs #{mass_kg} in kg. You might also find it intereesting that it is #{distance_from_sun_km} km away from Earth. The best part of planet #{name} is that it is #{fun_fact}." end end +#push! \ No newline at end of file diff --git a/solar_system.rb b/solar_system.rb index fb239980..871dc165 100644 --- a/solar_system.rb +++ b/solar_system.rb @@ -41,4 +41,5 @@ def create_planet end -end \ No newline at end of file +end +#push! \ No newline at end of file