Skip to content

Conversation

@aruna79
Copy link

@aruna79 aruna79 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? Initialize method creates initial parameters for class instead of nil values
Describe an instance variable you used and what you used it for. I used @planets as initial variable for solar system class and assigned planet to get the array of planets.
Describe what the difference would be if your SolarSystem used an Array vs a Hash. I used array of planets which is ordered and can easily access the planets using the index. Hashes are not ordered and would be difficult to access the planets.
Do you feel like you used consistent formatting throughout your code? yes

@CheezItMan
Copy link

Solar System

What We're Looking For

Feature Feedback
Baseline
Readable code with consistent indentation. No, you have some indentation problems, see my in-line comments. You should use Atom's tool to fix misalignments.
Primary Requirements
Created Custom Solar System Class with initialize, add planet & list planets methods, without using puts. Check, nicely done.
Planet Class Created Check
Created a collection of Planet objects as an instance variable in SolarSystem. Check
Helper methods created Check
Method created to return the Planet's attributes and not use puts Check
Created a user interface to interact with the SolarSystem including adding a planet and viewing a planet's details Yes, but see my notes about it. It doesn't let you add a planet in the main loop and never lets you view a planet once added.
Additional Notes Hashes are not ordered and would be difficult to access the planets. I'm not sure that's true, you could make the planet name a key, and thus it might be easier under some circumstances to access a Planet. You also have a problematic check method. Instead of using @planet to return a planet from the collection, you create a planet in that method and return it. This means that after the method finishes the newly created instance goes away, and isn't remembered in the instance variable. That also prevents you from using custom planets added with add_planet. Look carefully at this and ask me if needed for help.

if answer1 == "y"
print "Please enter the planet name"
new_planet = gets.chomp
print "Enter the desc"

Choose a reason for hiding this comment

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

You should give some space between the prompt and the input.

like: print "Enter the description ==> "

Same for all of the following.

#Start of user interface
print"Welcome to the Solar System\n"
answer = "y"
while answer.include?("y")

Choose a reason for hiding this comment

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

The main loop never lets you add a Planet until it's done. Then you can't view the Planet you added.


#Create Solar System Class
class SolarSystem
attr_accessor :planet

Choose a reason for hiding this comment

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

Why make planet an accessor? Why not a reader? Do you have a reason users would be able to change planet?

def check
choice=gets.chomp.to_i
if choice == 1
element = Planet.new("Mercury","Smallest planet","47.8km/sec","4878km","87.97days","70millionkm")

Choose a reason for hiding this comment

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

Why create new planets here? Why not simply return the Planet from @planet?

Look at this method closely? Think about how you could create a method that takes a number and returns the indicated planet from @planet. Get help from me or a tutor/TA if you need.

class SolarSystem
attr_accessor :planet
def initialize(planet)
@planet = planet

Choose a reason for hiding this comment

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

Since @planet is going to hold a list of planets, it should probably be plural (@planets as opposed to @planet).

end
end
#Method to add new planet from user input
def create_planet_userinput(new_planet,new_planet_desc,new_planet_orbit,new_planet_diameter,

Choose a reason for hiding this comment

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

You have this and following code indented, it shouldn't be.

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