Skip to content

Conversation

@Krashaune
Copy link

@Krashaune Krashaune 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? The initialize method is to define what instance variables are needed to create an object in the class.
Describe an instance variable you used and what you used it for. I used 5 instance variables in the class Planet which were name, position, color, attribute a, and attribute b. I used them to define what is needed to create a new planet.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. If Solarsystem used an array you could access the information and iterate over it using the index whereas with a hash in order to access the information (values) you would need to use the keys.
Do you feel like you used consistent formatting throughout your code? Yes, I believe I did.

@Krashaune Krashaune changed the title Kiera Kiera Thomasson - Octos - Solar System Feb 12, 2018
@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. yes
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 yes
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details some - adding a planet doesn't work, you get a new planet but every attribute is hard-coded
Additional Notes This is a good start, but it feels like there's a way to go still to get comfortable with classes and methods. I've left some specific inline comments below - please read through them, and try and practice those ideas this week on WordGuess and GroceryStore. I really appreciate all the hard work you were doing this weekend. Keep that focus and things will start to fall into place!

@@ -0,0 +1,142 @@
# wave 2

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"

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

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

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

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

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

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!

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