From 35544dd01fc92b7a874a97bc598f9a30e953a1fb Mon Sep 17 00:00:00 2001 From: ThePomodoro Date: Sun, 12 Jan 2014 22:51:45 -0800 Subject: [PATCH 1/2] Feature: Panda and Tiger --- .idea/Episode6.iml | 220 ++++++++++++++++++++++++++++++++ .idea/encodings.xml | 5 + .idea/misc.xml | 5 + .idea/modules.xml | 9 ++ .idea/scopes/scope_settings.xml | 5 + .idea/vcs.xml | 7 + models/Motorcycle.rb | 10 ++ models/Vehicle.rb | 8 ++ models/automobile.rb | 21 +++ spec/automobile_spec.rb | 38 ++++++ spec/motorcycle_spec.rb | 9 ++ spec/vehicle_spec.rb | 9 ++ 12 files changed, 346 insertions(+) create mode 100644 .idea/Episode6.iml create mode 100644 .idea/encodings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scopes/scope_settings.xml create mode 100644 .idea/vcs.xml create mode 100644 models/Motorcycle.rb create mode 100644 models/Vehicle.rb create mode 100644 models/automobile.rb create mode 100644 spec/automobile_spec.rb create mode 100644 spec/motorcycle_spec.rb create mode 100644 spec/vehicle_spec.rb diff --git a/.idea/Episode6.iml b/.idea/Episode6.iml new file mode 100644 index 0000000..9e2bdf8 --- /dev/null +++ b/.idea/Episode6.iml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..78d2e82 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..80603f8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..c80f219 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/models/Motorcycle.rb b/models/Motorcycle.rb new file mode 100644 index 0000000..e0a9ea7 --- /dev/null +++ b/models/Motorcycle.rb @@ -0,0 +1,10 @@ +require_relative('Vehicle.rb') +class Motorcycle < Vehicle + +attr_accessor :tires + + def initialize + @tires = 2 + end + +end \ No newline at end of file diff --git a/models/Vehicle.rb b/models/Vehicle.rb new file mode 100644 index 0000000..de9dd4c --- /dev/null +++ b/models/Vehicle.rb @@ -0,0 +1,8 @@ +class Vehicle + attr_accessor :tires + + def initialize (tires) + @tires = tires + end + +end \ No newline at end of file diff --git a/models/automobile.rb b/models/automobile.rb new file mode 100644 index 0000000..addf04e --- /dev/null +++ b/models/automobile.rb @@ -0,0 +1,21 @@ +require_relative('Vehicle.rb') +class Automobile < Vehicle + attr_accessor :wheels, :carspecifications, :colour, :make, :model, :year + + def initialize(wheels, carspecifications={}) + @carspecifications = carspecifications + @wheels = wheels + @colour = @carspecifications[:colour] + @make = @carspecifications[:make] + @model = @carspecifications[:model] + @year = @carspecifications[:year] + end + + def update(newspecs = {}) + @newspecs = newspecs + @colour = @newspecs[:colour] + @make = @newspecs[:make] + @model = @newspecs[:model] + @year = @newspecs[:year] + end +end \ No newline at end of file diff --git a/spec/automobile_spec.rb b/spec/automobile_spec.rb new file mode 100644 index 0000000..9867eaf --- /dev/null +++ b/spec/automobile_spec.rb @@ -0,0 +1,38 @@ +require 'rspec' +require_relative('../models/automobile.rb') + + +describe 'Automobile' do + carspecs = {colour: "Red", make: "Skoda", model: "Shiznit", year: "1970"} + mycar = Automobile.new(5, carspecs) + + it 'should return the number of wheels' do + mycar.wheels.should be_a_kind_of Numeric + end + + it "should have a colour" do + mycar.colour.should == carspecs[:colour] + end + + it "should have a make" do + mycar.make.should == carspecs[:make] + end + + it "should have a model" do + mycar.model.should == carspecs[:model] + end + + it "should have a year" do + mycar.year.should == carspecs[:year] + end + + it "should update specs" do + newspecs = {colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} + mycar.update(newspecs) + mycar.colour.should == newspecs[:colour] + mycar.make.should == newspecs[:make] + mycar.model.should == newspecs[:model] + mycar.year.should == newspecs[:year] + end + +end \ No newline at end of file diff --git a/spec/motorcycle_spec.rb b/spec/motorcycle_spec.rb new file mode 100644 index 0000000..8eab818 --- /dev/null +++ b/spec/motorcycle_spec.rb @@ -0,0 +1,9 @@ +require_relative('../models/Motorcycle.rb') +require 'rspec' + +describe Motorcycle do + it 'should return number of tires' do + Motorcycle.new.tires.should == 2 + end + +end \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb new file mode 100644 index 0000000..081eb27 --- /dev/null +++ b/spec/vehicle_spec.rb @@ -0,0 +1,9 @@ +require_relative('../models/Vehicle.rb') +require 'rspec' + +describe Vehicle do + it 'should return number of tires' do + Vehicle.new(4).tires.should be_a_kind_of Numeric + end + +end \ No newline at end of file From 78b20542899f97423ce2d2afcfe2ba30d18b2c7c Mon Sep 17 00:00:00 2001 From: ThePomodoro Date: Fri, 17 Jan 2014 20:37:32 -0800 Subject: [PATCH 2/2] Feature: Redid Panda-Tiger --- models/Vehicle.rb | 20 ++++++++++-- models/automobile.rb | 19 +++--------- spec/automobile_spec.rb | 67 +++++++++++++++++++++-------------------- spec/vehicle_spec.rb | 38 +++++++++++++++++++++-- 4 files changed, 92 insertions(+), 52 deletions(-) diff --git a/models/Vehicle.rb b/models/Vehicle.rb index de9dd4c..56f9f38 100644 --- a/models/Vehicle.rb +++ b/models/Vehicle.rb @@ -1,8 +1,22 @@ class Vehicle - attr_accessor :tires + attr_accessor :tires, :wheels, :colour, :make, :year, :model - def initialize (tires) - @tires = tires + def initialize (args={}) + @tires = args.fetch(:tires) + @wheels = args.fetch(:wheels) + @colour = args.fetch(:colour) + @make = args.fetch(:make) + @year = args.fetch(:year) + @model = args.fetch(:model) + end + + def update(args = {}) + @tires = args.fetch(:tires) + @wheels = args.fetch(:wheels) + @colour = args.fetch(:colour) + @make = args.fetch(:make) + @year = args.fetch(:year) + @model = args.fetch(:model) end end \ No newline at end of file diff --git a/models/automobile.rb b/models/automobile.rb index addf04e..5bd28a6 100644 --- a/models/automobile.rb +++ b/models/automobile.rb @@ -1,21 +1,12 @@ require_relative('Vehicle.rb') class Automobile < Vehicle - attr_accessor :wheels, :carspecifications, :colour, :make, :model, :year + attr_accessor :wheels, :carspecifications, :colour, :make, :year - def initialize(wheels, carspecifications={}) - @carspecifications = carspecifications - @wheels = wheels - @colour = @carspecifications[:colour] - @make = @carspecifications[:make] - @model = @carspecifications[:model] - @year = @carspecifications[:year] + def initialize(args = {}) + super(args) end - def update(newspecs = {}) - @newspecs = newspecs - @colour = @newspecs[:colour] - @make = @newspecs[:make] - @model = @newspecs[:model] - @year = @newspecs[:year] + def update(args = {}) + super(args) end end \ No newline at end of file diff --git a/spec/automobile_spec.rb b/spec/automobile_spec.rb index 9867eaf..2648dd4 100644 --- a/spec/automobile_spec.rb +++ b/spec/automobile_spec.rb @@ -3,36 +3,37 @@ describe 'Automobile' do - carspecs = {colour: "Red", make: "Skoda", model: "Shiznit", year: "1970"} - mycar = Automobile.new(5, carspecs) - - it 'should return the number of wheels' do - mycar.wheels.should be_a_kind_of Numeric - end - - it "should have a colour" do - mycar.colour.should == carspecs[:colour] - end - - it "should have a make" do - mycar.make.should == carspecs[:make] - end - - it "should have a model" do - mycar.model.should == carspecs[:model] - end - - it "should have a year" do - mycar.year.should == carspecs[:year] - end - - it "should update specs" do - newspecs = {colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} - mycar.update(newspecs) - mycar.colour.should == newspecs[:colour] - mycar.make.should == newspecs[:make] - mycar.model.should == newspecs[:model] - mycar.year.should == newspecs[:year] - end - -end \ No newline at end of file + carspecs = {wheels: 4, colour: "Red", make: "Shiznit", year: "1970", model: "Skoda"} + myauto = Vehicle.new(carspecs) + + it "should have a model" do + myauto.model.should == "Skoda" + end + + it 'should return the number of wheels' do + myauto.wheels.should be_a_kind_of Numeric + end + + it "should have a colour" do + myauto.colour.should == carspecs[:colour] + end + + it "should have a make" do + myauto.make.should == carspecs[:make] + end + + it "should have a year" do + myauto.year.should == carspecs[:year] + end + + it "should update specs" do + newspecs = {wheels: 4, colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} + myauto.update(newspecs) + myauto.tires.should == newspecs[:tires] + myauto.wheels.should == newspecs[:wheels] + myauto.colour.should == newspecs[:colour] + myauto.make.should == newspecs[:make] + myauto.model.should == newspecs[:model] + myauto.year.should == newspecs[:year] + end + end \ No newline at end of file diff --git a/spec/vehicle_spec.rb b/spec/vehicle_spec.rb index 081eb27..0e9032a 100644 --- a/spec/vehicle_spec.rb +++ b/spec/vehicle_spec.rb @@ -2,8 +2,42 @@ require 'rspec' describe Vehicle do + carspecs = {tires: 4, wheels: 4, colour: "Red", make: "Shiznit", year: "1970", model: "Skoda"} + myvehicle = Vehicle.new(carspecs) + it 'should return number of tires' do - Vehicle.new(4).tires.should be_a_kind_of Numeric + myvehicle.tires.should be_a_kind_of Numeric end -end \ No newline at end of file + it "should have a model" do + myvehicle.model.should == "Skoda" + end + + it 'should return the number of wheels' do + myvehicle.wheels.should be_a_kind_of Numeric + end + + it "should have a colour" do + myvehicle.colour.should == carspecs[:colour] + end + + it "should have a make" do + myvehicle.make.should == carspecs[:make] + end + + it "should have a year" do + myvehicle.year.should == carspecs[:year] + end + + it "should update specs" do + newspecs = {tires: 4, wheels: 4, colour: "Yellow", make: "Toyota", model: "Corolla", year: "2003"} + myvehicle.update(newspecs) + myvehicle.tires.should == newspecs[:tires] + myvehicle.wheels.should == newspecs[:wheels] + myvehicle.colour.should == newspecs[:colour] + myvehicle.make.should == newspecs[:make] + myvehicle.model.should == newspecs[:model] + myvehicle.year.should == newspecs[:year] + end + end +