-
Notifications
You must be signed in to change notification settings - Fork 44
Kiera Thomasson - Octos - Solar System #37
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
base: master
Are you sure you want to change the base?
Conversation
Solar SystemWhat We're Looking For
|
| @@ -0,0 +1,142 @@ | |||
| # wave 2 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Files in Ruby should be named using snake_case. So this one would be solar_system.rb (little 's').
The decision is a little arbitrary, but especially once we start working on group projects it will be important to make sure everyone is doing the same thing.
| summary = "" | ||
| i = 1 | ||
| @planet_list.each do |planet| | ||
| summary += "#{i}.#{planet.summary_sol}\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 32 gave me an error. Looks like the planet_user method is probably what you want.
|
|
||
| def summary_sol | ||
| return "The planets name is #{@name}. It is in the #{@position} position in the solar system. It is #{@color}. It has two random attributes that are #{@attr_a} and #{@attr_b}." | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this method makes sense in the context of SolarSystem. It relies on instance variables like @name and @position, which are defined in Planet but not here.
| new_planet << new_planet_name | ||
| puts "Choose a planet position (number cannot be 1-5)" | ||
| new_planet_position = gets.chomp | ||
| new_planet << new_planet_position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're shoveling these variables into an array - I'm not sure that's what you want. Instead, you should use them as the arguments to call Planet.new, and add that to your solar system:
puts "Choose a planet name"
new_planet_name = gets.chomp
puts "Choose a planet position..."
new_planet_position = gets.chomp
# ... rest of the attributes
new_planet = Planet.new(new_planet_name, new_planet_position, ...)
my_solar_system.add_planet(new_planet)| # add new planet to list | ||
| def add_planet(name, position, color, attr_a, attr_b) | ||
| return @planet_list << planet_list | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should take one argument, an instance of Planet, and add it to the list. As is I think it will throw an error.
|
|
||
| print planet_g | ||
|
|
||
| planet_list << planet_g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In stead of referencing the planet_list directly here, you should go through your instance of SolarSystem: my_solar_system.add_planet. This may seem rounabout, but by making the solar system is the owner of the list of planets and requiring that all access goes through it, we can make our programs easier to reason about and debug.
| attr_accessor :name, :position, :color, :attr_a, :attr_b | ||
| # add an initialize method that will take in multiple arguments | ||
| def initialize(name, position, color, attr_a, attr_b) | ||
| @name = name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that you took our placeholder attributes and ran with them!
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initializemethod in your class?SolarSystemused anArrayvs aHash.