-
Notifications
You must be signed in to change notification settings - Fork 22
only a trouble with eagle, how does one filter? #22
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,35 @@ | ||
| class Automobile | ||
| def initialize(color, make, model, year) | ||
| @color = color | ||
| @make = make | ||
| @model = model | ||
| @year = year | ||
| end | ||
|
|
||
| def number_of_wheels | ||
| number_of_wheels = 4 | ||
| end | ||
|
|
||
| automobile = {} | ||
| automobile[:color] = "Red" | ||
| automobile[:make] = "SUV" | ||
| automobile[:model] = "Honda" | ||
| automobile[:year] = 2008 | ||
|
|
||
| Car = Struct.new(:automobile, :method) | ||
| car = Car.new( {color: "Blue", make: "BMW", model: "sedan", year: 2013} ) | ||
| end | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # Panda Assignment | ||
| # ---------------- | ||
|
|
||
| # 1. Create a class definition for an automobile | ||
| # 2. The class should have the following characteristics: | ||
| # * Should have a class method that returns the number of wheels it has | ||
| # * Should have instance variables for color, make, model, and year | ||
| # * I should be able to pass in a hash of color, make, model, and year to the class to update its variables | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| class Vehicle < Automobile | ||
|
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. You should have Vehicle as the base class, which Automobile inheriting from it. class Automobile < Vehicle |
||
|
|
||
| @@vehicles = [] | ||
| vehicle = Vehicle.new | ||
| @@vehicles.push(vehicle) | ||
|
|
||
|
|
||
| def filter? | ||
| vehicle = Vehicle.new | ||
| if vehicle.color == "blue" && vehicle.make == "honda" && vehicle.model = "accord" | ||
| end | ||
|
|
||
| end | ||
|
|
||
| class Motorcycle < Vehicle | ||
| def number_of_tires | ||
| number_of_tires = 2 | ||
| end | ||
| end | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # Tiger Assignment | ||
| # ---------------- | ||
|
|
||
| # 1. Create a Vehicle class that automobile inherits from | ||
| # 2. Create a Motorcycle class that inherits from vehicle | ||
| # 3. Show the motorcycle class overriding the vehicle's class method for number of tires | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| class Vehicle | ||
| end | ||
|
|
||
| describe Vehicle do | ||
| it "should track all the vehicles made" do | ||
| @@vehicles = [] | ||
|
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. at this point, you're testing ruby array code. You shouldn't have count = Vehicle.vehicle_count
Vehicle.new
Vehicle.vehicle_count.should eq(count+1)or, a little easier to read: expect {
Vehicle.new
}.to change(Vehicle, :vehicle_count).by(1) |
||
| vehicle = Vehicle.new | ||
| @@vehicles.push(vehicle) | ||
| @@vehicles.length.should eq(1) | ||
| end | ||
|
|
||
| it "should filter blue honda accords" do | ||
| vehicle = Vehicle.new | ||
| vehicle.filter? | ||
| end | ||
| end | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # Eagle Assignment | ||
| # ---------------- | ||
|
|
||
| # 1. Create a class variable (@@) in the Vehicle that tracks all vehicles mde | ||
| # 2. Create a class method that let's you filter the vehicles to only blue honda accords (using our enuerable filters) | ||
| # 3. Do it all using TDD (of course!) | ||
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.
This should not be inside your Automobile class definition