-
Notifications
You must be signed in to change notification settings - Fork 44
Ampers Solar system Aruna #22
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
|
| if answer1 == "y" | ||
| print "Please enter the planet name" | ||
| new_planet = gets.chomp | ||
| print "Enter the desc" |
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 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") |
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 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 |
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.
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") |
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.
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 |
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.
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, |
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 have this and following code indented, it shouldn't be.
Solar System
Congratulations! You're submitting your assignment.
Comprehension Questions
initializemethod in your class?SolarSystemused anArrayvs aHash.