Skip to content

Conversation

@CheerOnMars
Copy link

@CheerOnMars CheerOnMars commented Feb 12, 2018

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
What was the purpose of the initialize method in your class? It acts as a constructor for each new object
Describe an instance variable you used and what you used it for. I used radius to record the radius for each planet
Describe what the difference would be if your SolarSystem used an Array vs a Hash. If I use an Array, I can used the index to order the array, which I found helpful in wave 3. The Hash could be helpful in keeping track of the attributes of each planet and adding additional attributes.
Do you feel like you used consistent formatting throughout your code? Mostly

@tildeee
Copy link

tildeee commented Feb 14, 2018

Solar System

What We're Looking For

Feature Feedback
Baseline
Readable code with consistent indentation. a syntax error at the end
Primary Requirements
Created Custom Solar System Class with initialize, add planet & list planets methods, without using puts. created, but didn't use the SolarSystem class, doesn't have/utilize add planet or list planets
Planet Class Created x
Created a collection of Planet objects as an instance variable in SolarSystem.
Accessor methods created x
Method created to return the Planet's attributes and not use puts x, but the instance methods aren't quite correct syntax
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details x
Additional Notes

For this submission, I only looked at the file solar_system_wave3.rb
When I ran that file, there was a syntax file in it and it didn't run. I had to make some changes to make it run, and I'm adding a comment on the code about that.

Good job on the project, it runs as expected

Right now, the container for Planet objects that you've made is the array planet_arr. While it works, the project would have benefited if you made an instance of the SolarSystem class:

my_solar_system = SolarSystem.new(planet_arr)
class SolarSystem
  def initialize(planets)
    @planets = planets
  end
  #...
end

The SolarSystem class would have an instance variable inside of it @planets that would essentially be planet_arr, so instead of every time you made planet_arr you would call my_solar_system.planets.

Also I'm adding a comment about a small bug in your code :)

Good work!

puts "You did not enter a valid option. Goodbye"
end

end
Copy link

@tildeee tildeee Feb 14, 2018

Choose a reason for hiding this comment

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

the code starting at line 103 through the end of the file should read instead:

  planet_arr.each_with_index do |planet, i|
    puts "#{i+1}. #{planet.summary} "
  end
else
  puts "You did not enter a valid option. Goodbye"
end

learn_option = gets.chomp.to_i
end
end
puts planet_arr[learn_option-1].summary
Copy link

Choose a reason for hiding this comment

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

starting at line 81, you have a small bug!

when gets.chomp.to_i executes on line 81, if I type in a non-integer (like "asdlfkjasdf"), then the value of learn_option will default to 0.

Because learn_option is 0, it will skip over the until block on line 83, and then jump straight to line 93. if learn_option is 0, then planet_arr[0-1] will mean planet_arr[-1], which will always choose the last element in the array.

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