Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions automobile.rb
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
Copy link
Member

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 car should handle "putting" its values to the screen.

myride = { "color" => "blue", "make" => "chevy", "year" => :"2000" }
myride.each_value {|value| puts value }
end
end

mycar = Automobile.new('Cyberblue', 'Chevy', 2012)
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The 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
trouble. Dana

On Fri, May 9, 2014 at 7:48 AM, Jesse Wolgamott [email protected]:

In automobile.rb:

  • def car
  • myride = { "color" => "blue", "make" => "chevy", "year" => :"2000" }
  • myride.each_value {|value| puts value }
  • end
    +end

+mycar = Automobile.new('Cyberblue', 'Chevy', 2012)

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?


Reply to this email directly or view it on GitHubhttps://github.com//pull/24/files#r12478917
.

Dana Nourie
http://www.dananourie.com

puts mycar.to_s
mycar.car