forked from AdaGold/solar-system
-
Notifications
You must be signed in to change notification settings - Fork 43
Jocelyn Gonzalez -- Carets #40
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
jocegonz
wants to merge
2
commits into
Ada-C8:master
Choose a base branch
from
jocegonz:patch-1
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,89 @@ | ||
|
|
||
| class SolarSystem | ||
| attr_reader :ss_user_choice | ||
|
|
||
| def initialize(ss) | ||
| @ss = ss | ||
| end | ||
|
|
||
|
|
||
| def ss_user_choice | ||
| puts "Here are your planets:" | ||
| @ss.each do |ss_planet| | ||
| puts ss_planet.name | ||
| end | ||
| puts "What planet do you want to learn more about? Please properly capitalize:" | ||
| # currently only accepts capitalized planets | ||
| planet_choice = gets.chomp | ||
| @ss.each do |ss_planet| | ||
| if planet_choice == ss_planet.name | ||
| puts ss_planet.print_planet | ||
| # else statement is always printing. not sure why | ||
| # else | ||
| # puts "Sorry, you inputted an invalid planet" | ||
| # exit | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| class Planet | ||
| attr_accessor :name, :moons, :year_length, :distance_from_the_sun, :named_after, :print_planet | ||
|
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. Again, you don't need to add |
||
|
|
||
| def initialize(name, moons, year_length, distance_from_the_sun, named_after) | ||
| @name = name | ||
| @moons = moons | ||
| @year_length = year_length | ||
| @distance_from_the_sun = distance_from_the_sun | ||
| @named_after = named_after | ||
| end | ||
|
|
||
| #FINAL PRINTS INDIVIDUAL PLANET DESCRIPTIONS | ||
| def print_planet | ||
| print_print_planet = | ||
| "WAVE2 This is the planet #{@name} | ||
| WAVE2 It has #{@moons} moon(s) | ||
| WAVE2 A year length is #{@year_length} | ||
| WAVE2 It is #{@distance_from_the_sun} from the sun | ||
| WAVE2 It is named after the #{@named_after}.\n\n" | ||
|
|
||
| return print_print_planet | ||
| end | ||
|
|
||
| end | ||
| #end Planet class | ||
|
|
||
| def add_new_planet(ss) | ||
| puts "Hello! Let's add a planet! What's is its name?" | ||
| user_planet_name = gets.chomp | ||
| puts "How many moons does it have?" | ||
| user_planet_moons = gets.chomp | ||
| puts "How long does a year take?" | ||
| user_planet_year_length = gets.chomp | ||
| puts "What's its distance from the sun?" | ||
| user_planet_distance_from_the_sun = gets.chomp | ||
| puts "Who is it named after?" | ||
| user_planet_named_after = gets.chomp | ||
|
|
||
| user_planet = Planet.new(user_planet_name, user_planet_moons, user_planet_year_length, user_planet_distance_from_the_sun, user_planet_named_after) | ||
| ss << user_planet | ||
| return ss | ||
| end | ||
|
|
||
|
|
||
|
|
||
| mercury = Planet.new("Mercury", 0, "88 days", "0.39 AU", "Roman god of travel") | ||
| venus = Planet.new("Venus", 0, "225 days", "0.72 AU", "Roman goddess of love and beauty") | ||
| earth = Planet.new("Earth", 0, "365 days", "1 AU", "the ground") | ||
| mars = Planet.new("Mars", 2, "1.88 years", "1.52 AU", "Roman god of war") | ||
| jupiter = Planet.new("Jupiter", 67, "11.86 years", "5.2 AU", "king of the Roman gods") | ||
| saturn = Planet.new("Saturn", 60, "29.46 years", "9.58 AU", "Roman god of agriculture") | ||
| uranus = Planet.new("Uranus", 27, "84.01 years", "19.2 AU", "ancient Greek king of the gods") | ||
| neptune = Planet.new("Neptune", 14, "164.75 years", "30.05 AU", "Roman god of the sea") | ||
| ss = [mercury, venus, earth, mars, jupiter, saturn, uranus, neptune] | ||
| ss = add_new_planet(ss) | ||
|
|
||
| new_solar_system = SolarSystem.new(ss) | ||
|
|
||
|
|
||
| new_solar_system.ss_user_choice | ||
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.
I don't think you need an
attr_readerforss_user_choice-- you've definedss_user_choiceas the name of a method.attr_readerhelps make method definitions if you give it an instance variable.