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

Create ss_wave_2.rb #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Jcornick21
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What was the purpose of the initialize method in your class? to set the state for objects from that class
Describe an instance variable you used and what you used it for. its a variable that allows information to be seen by the object to which it is assigned. I used them to build methods to be used on objects of my classes
Describe what the difference would be if your SolarSystem used an Array vs a Hash. How I would iterate through information and assign user input would be very different.
Do you feel like you used consistent formatting throughout your code? no, though I tried

@droberts-sea
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Readable code with consistent indentation. yes
Primary Requirements
Created Custom Solar System Class with initialize, add planet & list planets methods, without using puts. some - you puts instead of return in a couple places
Planet Class Created yes
Created a collection of Planet objects as an instance variable in SolarSystem. yes
Accessor methods created yes
Method created to return the Planet's attributes and not use puts some, some puts
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details yes
Additional Notes Good work overall. It seems like there are still some spots where you're a little shaky around working with methods and classes - keep practicing these, and proficiency will come. I've left a few comments inline below, please review these and keep them in mind as you work on GroceryStore. Keep up the hard work!

def pick_planet(user_pick)
@ss.each do |planets|
if planets.planet_name == user_pick
puts "#{planets.details}\n\n\n#{planets.planet_attributes}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the idea of this method! One way you might make it more flexible is to return the Planet itself, rather than putsing a string. That way, the caller could do whatever they like with it.

if solar_system.planet_list.include?(planet_choice)
return solar_system.pick_planet(planet_choice)
else
while solar_system.planet_list.include?(planet_choice) == false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditions for the if and the while here are a little redundant. Maybe this code could be refactored to something like:

planet_choice = nil
until solar_system.planet_list.include?(planet_choice)
  puts "Please choose a planet"
  planet_choice = gets.chomp.downcase.capitalize
end
solar_system.pick_planet(planet_choice)

planet_choice = gets.chomp.downcase.capitalize
return solar_system.pick_planet(planet_choice)

end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have a return in your while loop here, the loop body will only ever execute once!


def initialize(planet_1, planet_2 )
@ss = [planet_1, planet_2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this certainly works, we were expecting you to pass a list of planets directly into SolarSystem.new, rather than passing planets one by one. So something like:

class SolarSystem
  attr_accessor :ss
  def initialize(planets)
    @ss = planets
  end
  # ... rest of the class ...
end

planet_a = Planet.new("Jupiter","1882","details")
planet_b = Planet.new("Uranus", "1932","about")
planet_list = [planet_a, planet_b]

my_ss = SolarSystem.new(planet_list)

That way whoever creates the instance of SolarSystem can create it with as many planets as needed.

if user_create == "y" || user_create == "yes"
user_planet_name
user_planet = gets.chomp
puts "when was your planet discovered?"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is almost exactly the same as the planet creation code you've got starting on line 166. Could you consolidate the two somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants