diff --git a/models/automobile.rb b/models/automobile.rb new file mode 100644 index 0000000..eae2f9d --- /dev/null +++ b/models/automobile.rb @@ -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 diff --git a/models/vehicle.rb b/models/vehicle.rb new file mode 100644 index 0000000..efb96d4 --- /dev/null +++ b/models/vehicle.rb @@ -0,0 +1,36 @@ +class Vehicle < Automobile + + @@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 + + diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb new file mode 100644 index 0000000..60ad8fb --- /dev/null +++ b/spec/vehicle_spec.rb @@ -0,0 +1,27 @@ +class Vehicle +end + +describe Vehicle do + it "should track all the vehicles made" do + @@vehicles = [] + 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!) \ No newline at end of file