-
Notifications
You must be signed in to change notification settings - Fork 22
completed panda & tiger assignments #13
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 all commits
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,20 @@ | ||
class Automobile | ||
|
||
@number_of_wheels | ||
@color | ||
@make | ||
@model | ||
@year | ||
|
||
def set_number_of_wheels | ||
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. This set_number_of_wheels would only be executed when you call it. It might be better to: def initialize
@number_of_wheels = 4
end Then, it would get executed when you create the Automobile object. |
||
@number_of_wheels = 4 | ||
end | ||
|
||
def update(hsh) | ||
@color = {hsh[:color]} | ||
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. You don't want to wrap the hsh with {} when you access it. you'll want to: @color = hsh[:color] On naming --- the convention here would be to spell out hash. Though, a further convention in ruby is to name this "args" or "params" (don't ask me why we don't spell out arguments. too long, prolly). |
||
@make = {hsh[:make]} | ||
@model = {hsh[:model]} | ||
@year = {hsh[:year]} | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Motorcycle < Vehicle | ||
|
||
def set_number_of_wheels | ||
@number_of_wheels = 2 | ||
end | ||
|
||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Vehicle < Automobile | ||
|
||
end |
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.
In Ruby, you don't need to pre-declare your instance variables like this. You can just start using them later