Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
21 changes: 21 additions & 0 deletions models/vehicle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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