-
Notifications
You must be signed in to change notification settings - Fork 48
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
Sockets-Bita #48
base: master
Are you sure you want to change the base?
Sockets-Bita #48
Conversation
Solar SystemWhat We're Looking For
This is a good start, and the code you've written does address the problem. However, there are a large number of small issues with your code, either where it doesn't quite match what we've asked for, or where it's not as clean as it should be. This sort of sloppiness will become more and more of a problem for you as our projects become more complicated and open-ended. There are two things you can do to help address this:
All that being said, this code does work, and I do believe that the specific learning goals for this assignment were met. Keep working on making your code clean, and keep up the hard work! |
if x == 1 | ||
list = solar_system.list_planets | ||
puts list | ||
elsif x == 3 |
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.
The user should be able to type a command like "list planets" or "quit" for these, not a number.
Also, why are your numbered options out of order? That makes this code just a bit more confusing.
elsif x == 4 | ||
puts "What is the name of the name of the planet you want to add?" | ||
name = gets.chomp | ||
puts "What is the color of your planet?" |
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.
The code to view planet details and to add a planet ends up being pretty big. It might be wise to isolate each of these in its own method.
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.
Also, this is a big long block of code with no breaks. You should split it up using empty lines.
|
||
earth = Planet.new("Earth", "blue-green", "5.972e24", "1.496e8", "Only planet known to support life") | ||
puts earth.name | ||
puts earth.fun_fact |
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.
Here you are creating an instance of Planet
inside that class. I'm not sure if this will work, or what effect it will have.
In general, please remove all debugging work before submitting your assignment.
def find_planet_by_name(name) | ||
#raise ArgumentError unless @planet.include?(name.capitalize) | ||
@planets.find { |planet| planet.name.downcase == name.downcase } | ||
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.
Good use of an enumerable here.
"#{index + 1}" + "." + item.name | ||
} | ||
puts "Planets orbiting Sun are: " | ||
return rotating_planets |
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.
Instead of puts
ing here, you should add the output on line 22 to the string you return.
x = 1 | ||
while x != 2 | ||
puts "What would you like to do?" | ||
puts "1. List planet" |
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 that I like the variable name x
here - could you call this something more descriptive? Maybe user_choice
?
|
||
def add_planets(planet) | ||
@planets.push(planet) | ||
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.
Small nitpick: the spec asked for a method named add_planet
, not add_planet
. This may seem like a small thing, but this sort of error makes everything a little more complex, especially when working with a big team of engineers. Software engineering is all about attention to detail.
Since the method only adds one planet at a time, add_planet
is definitely the right choice.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initialize
method run? What does it do?Hash
instead of an instance of a class?SolarSystem
class used aHash
instead of anArray
to store the list of planets?require
statements? Which files neededrequire
s, and which did not? What is the pattern?Notes to Instructors: I made a couple of mistakes throughout this project. the first one was that I did git init and then added and commited after each wave by the time I realized I was almost done so there is no commit message after every step in my project, then I totally forgot to submit my project on time and didn't do a pull request last night. I made some notes for myself to prevent the same mistakes on the next projects!