Skip to content

Episode6 - Assignments #18

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
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions models/automobile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Automobile < Vehicle

attr_accessor :color, :make, :model, :year

def initialize(color, make, model, year)
@color = color
@make = make
@model = model
@year = year
end

end
5 changes: 5 additions & 0 deletions models/motorcycle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Motorcycle < Vehicle
def self.tires
2
end
end
19 changes: 19 additions & 0 deletions models/vehicle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Vehicle

@@allvehicles = []

def initialize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With class variables, just doing is enough to initialize them. so your def initialize isn't needed

@@allvehicles = []

@@allvehicles << self
end

def self.tires
4
end

def self.filter
@@allvehicles.select do |i|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is SO CLOSE, awesome job!

If you check this code out, I think you'll see that it only matches on the model of "Accord". So a Black Toyota Accord would match.

But if you:

i.color == "Blue" && i.make == "Honda" && i.model == "Accord"

you'd have it!

i.color == "Blue" && i.make == "Honda" && i.model == "Accord"
end
end

end