-
Notifications
You must be signed in to change notification settings - Fork 22
Created Automobile class with attributes and hash #24
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| class Automobile | ||
| @@wheels = 4 | ||
|
|
||
| def initialize(color, make, year) | ||
| @color = color | ||
| @make = make | ||
| @year = year | ||
| end | ||
|
|
||
| def to_s | ||
| "My car is #{@color}, its make is #{@make}, and #{@year}" | ||
| end | ||
|
|
||
| def car | ||
| myride = { "color" => "blue", "make" => "chevy", "year" => :"2000" } | ||
| myride.each_value {|value| puts value } | ||
| end | ||
| end | ||
|
|
||
| mycar = Automobile.new('Cyberblue', 'Chevy', 2012) | ||
|
Member
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. There's a "rule" in Ruby that if you have 0, 1, or 2 parameters, then it's okay to have parameters like you did. Otherwise, you should use a hash, like so: Automobile.new(color: 'Cyberblue', make: 'Chevy', year: 2012)What changes will you have to make to accept that change?
Author
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. Jesse, did you see my last pull request? I rewrote the class but am having On Fri, May 9, 2014 at 7:48 AM, Jesse Wolgamott notifications@github.comwrote:
Dana Nourie |
||
| puts mycar.to_s | ||
| mycar.car | ||
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.
If Automobile defines the data of a car, then I don't think the method
carshould handle "putting" its values to the screen.