forked from AdaGold/solar-system
-
Notifications
You must be signed in to change notification settings - Fork 34
Queues-Allison-Northrop-Create solar_system.rb #45
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
Open
Allison-Northrop
wants to merge
2
commits into
Ada-C7:master
Choose a base branch
from
Allison-Northrop:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #creating a class named planets | ||
| puts "What planet would you like to learn about?" | ||
| puts "1. Earth | ||
| 2. Mars | ||
| 3. Jupiter | ||
| 4. Venus" | ||
|
|
||
| planet_choice = gets.chomp.downcase | ||
|
|
||
| class Planet | ||
| attr_accessor :name, :color, :moons, :mass, :diameter, :solar_rotation, :distance_from_sun | ||
|
|
||
| def initialize(planet_hash) | ||
| @name = planet_hash[:name] | ||
| @color = planet_hash[:color] | ||
| @moons = planet_hash[:moons] | ||
| @mass = planet_hash[:mass] | ||
| @diameter = planet_hash[:diameter] | ||
| @solar_rotation = planet_hash[:solar_rotation] | ||
| @distance_from_sun = planet_hash[:distance_from_sun] | ||
| end | ||
|
|
||
| def planet_paragraph | ||
| return "The planet #{name} is a #{color} planet with #{moons} moon(s). #{name} has a #{mass} mass and is #{diameter}" \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that you |
||
| + " miles in diameter. The planet has a #{solar_rotation} hour day and is #{distance_from_sun} miles away from the sun." | ||
| end | ||
|
|
||
| end | ||
|
|
||
| earth = Planet.new(name: "Earth", color: "blue, green, white and brown", moons: 1, mass: 5.972 * 10**32, diameter: 7899, solar_rotation: 24, distance_from_sun: 92960000) | ||
| mars = Planet.new(name: "Mars", color: "red", moon: 2, mass: 6.39 * 10**23, diameter: 4220, solar_rotation: 24, distance_from_sun: 141600000) | ||
| jupiter = Planet.new(name: "Jupiter", color: "red, white and brown", moon: 53, mass: 1.898 * 10**27, diameter: 86881000000, solar_rotation: 10, distance_from_sun: 483800000) | ||
| venus = Planet.new(name: venus, color: "yellowish white", moon: 0, mass: 4.867 * 10**24, diameter: 7520, solar_rotation: 2802, distance_from_sun: 670240000) | ||
|
|
||
|
|
||
| case planet_choice | ||
| when "earth", "1" | ||
| puts earth.planet_paragraph | ||
| when "mars", "2" | ||
| puts mars.planet_paragraph | ||
| when "jupiter", "3" | ||
| puts jupiter.planet_paragraph | ||
| when "venus", "4" | ||
| else | ||
| puts "That's not a planet on the list, silly!" | ||
| end | ||
|
|
||
| class SolarSystem | ||
| attr_accessor :planets | ||
| def initialize (planets) | ||
| @planets = [] | ||
| end | ||
|
|
||
| def add_planet(planet) | ||
| @planets.push(planet) | ||
| end | ||
| end | ||
| planetary_system = SolarSystem.new("saturn") | ||
| # planetary_system.add_planet(Planet.new("something about saturn")) | ||
| # planetary_system.add_planet(SolarSystem.new("Uranus", nil, nil, nil, nil, nil, nil)) | ||
|
|
||
| puts planetary_system | ||
|
|
||
| #don't forget to delete this | ||
| #some change here to commite for github | ||
|
|
||
|
|
||
|
|
||
| # Create a SolarSystem class that has an attribute planets that has zero to many Planet instances. | ||
| # There are a few different options for how to associate the planets with your solar system: | ||
| # Create a method that adds a single planet to a solar system | ||
| # Create a method that adds a list of planets to an existing list of planets | ||
| # Use an array to store a list of objects | ||
| # Create and use a method | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 job re-working
Planet#initializeto take a hash.