Skip to content

Branches -Amal #46

Open
ashassan wants to merge 12 commits intoAda-C12:masterfrom
ashassan:master
Open

Branches -Amal #46
ashassan wants to merge 12 commits intoAda-C12:masterfrom
ashassan:master

Conversation

@ashassan
Copy link

Solar System

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
When does the initialize method run? What does it do? the initialize method runs when you call .new. It allows you to add parameters to .new and save them as instance variables.
Why do you imagine we made our instance variables readable but not writable? We made them readable so that we could access them later. We didn't need to reassign the values ever so we didn't need accessor writers.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? You would have to make keys for each detail (name, fun fact, etc.) . You would have to create a hash for each planet you want to add. We would also have to access things differently and possibly create more methods.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? I would have to have a key for each planet. I would also have to change the way I add things to it.
There is a software design principle called the SRP. The Single Responsibility Principle (SRP) says that each class should be responsible for exactly one thing. Do your classes follow SRP? What responsibilities do they have? Yes, because everything in the planet class is related to planets and it doesn't call on anything from other classes. The solar system is also related to things in a solar system so I believe it follows it too.
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? I used require in the main.rb because I was using things from the other files. I did not use requires for my class definition files because they didn't call on any other files.

@jmaddox19
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Whitespace (indentation, vertical space, etc) X
Variable names X
Git hygiene Great job adding lots of incremental commits!
Planet
initialize method stores parameters as instance variables with appropriate reader methods X
summary method returns a string X
SolarSystem
initialize creates an empty list of planets X
add_planet takes an instance of Planet and adds it to the list X
list_planets returns a string X
find_planet_by_name returns the correct instance of Planet X
CLI
Can list planets and quit X
Can show planet details X
Can add a planet X
Complex functionality is broken out into separate methods X
Overall Great! Very above and beyond to write your own tests and add a Rakefile! So cool!!! 👏 👏

@@ -0,0 +1,28 @@
class Planet
attr_reader :name, :color, :mass_kg, :distance_from_sun_km, :fun_fact
def initialize (name:, color:, mass_kg:, distance_from_sun_km:, fun_fact:)

Choose a reason for hiding this comment

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

love that you used keyword arguments here!

@fun_fact = fun_fact

if @mass_kg <= 0
raise ArgumentError.new "invalid input less than 0 "

Choose a reason for hiding this comment

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

Great that you validated here!
This would've been above and beyond but wanted to mention that the next step would be to handle (or "rescue") the error in the input_add_planet method so that the user can see an error message and try again rather than the program exiting.

when "leave"
choice = false
when "planet details"
planet_details(my_solar_system)

Choose a reason for hiding this comment

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

love that you broke the more complex stuff into separate methods!

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