Skip to content
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

Feature: Panda and Tiger #17

Open
wants to merge 2 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
220 changes: 220 additions & 0 deletions .idea/Episode6.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions models/Motorcycle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require_relative('Vehicle.rb')
class Motorcycle < Vehicle

attr_accessor :tires

def initialize
@tires = 2
end

end
22 changes: 22 additions & 0 deletions models/Vehicle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Vehicle
attr_accessor :tires, :wheels, :colour, :make, :year, :model

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
12 changes: 12 additions & 0 deletions models/automobile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require_relative('Vehicle.rb')
class Automobile < Vehicle
attr_accessor :wheels, :carspecifications, :colour, :make, :year

def initialize(args = {})
super(args)
end

def update(args = {})
super(args)
end
end
39 changes: 39 additions & 0 deletions spec/automobile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'rspec'
require_relative('../models/automobile.rb')


describe 'Automobile' do
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
9 changes: 9 additions & 0 deletions spec/motorcycle_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading