From c64b49e3a01849ef3304db77478dd5d629e17e32 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:09:40 +0100 Subject: [PATCH 01/14] First Commit - Created spec file --- spec/airport_challenge_spec.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spec/airport_challenge_spec.rb diff --git a/spec/airport_challenge_spec.rb b/spec/airport_challenge_spec.rb new file mode 100644 index 0000000000..b15c0a2ec2 --- /dev/null +++ b/spec/airport_challenge_spec.rb @@ -0,0 +1,2 @@ +require './docs/airport_challenge' + From 9cbd86605afc3eb44f4fd42b57592913a1b78cdf Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:10:40 +0100 Subject: [PATCH 02/14] Added Airport class --- docs/airport_challenge.rb | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 docs/airport_challenge.rb diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb new file mode 100644 index 0000000000..2b5c17a697 --- /dev/null +++ b/docs/airport_challenge.rb @@ -0,0 +1,3 @@ +class Airport + +end From d1f89761ed10392cf2355c353915110e91331d5a Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:11:18 +0100 Subject: [PATCH 03/14] Added airport instance test --- spec/airport_challenge_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/airport_challenge_spec.rb b/spec/airport_challenge_spec.rb index b15c0a2ec2..45258249ce 100644 --- a/spec/airport_challenge_spec.rb +++ b/spec/airport_challenge_spec.rb @@ -1,2 +1,8 @@ require './docs/airport_challenge' - +describe Airport do + it 'can create an instance of airport' do + airport = Airport.new + expect(airport).to be_kind_of(Airport) + end + +end From b8ea842a8f99e0c448bc93548bf537812de23ad6 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:17:21 +0100 Subject: [PATCH 04/14] Changed name --- spec/{airport_challenge_spec.rb => airport_spec.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{airport_challenge_spec.rb => airport_spec.rb} (100%) diff --git a/spec/airport_challenge_spec.rb b/spec/airport_spec.rb similarity index 100% rename from spec/airport_challenge_spec.rb rename to spec/airport_spec.rb From a5a418bfd317d1599bf7318ec7ee1d5ed1444b25 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:19:31 +0100 Subject: [PATCH 05/14] Created plane spec & instance test --- spec/plane_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 spec/plane_spec.rb diff --git a/spec/plane_spec.rb b/spec/plane_spec.rb new file mode 100644 index 0000000000..91d1326050 --- /dev/null +++ b/spec/plane_spec.rb @@ -0,0 +1,7 @@ +describe Plane do + + it 'creates instance of plane' do + plane = Plane.new + expect(plane).to be_kind_of(airport) + end +end \ No newline at end of file From aa08f700a775e8e6acd877e014e199d4dd9a820b Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:26:41 +0100 Subject: [PATCH 06/14] Added Plane class --- docs/airport_challenge.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index 2b5c17a697..8c7d8f6055 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -1,3 +1,7 @@ class Airport end + +class Plane + +end \ No newline at end of file From 66408f1892e0b0abd318538fa5792da17dc3d859 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:51:33 +0100 Subject: [PATCH 07/14] added land test --- spec/airport_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/airport_spec.rb b/spec/airport_spec.rb index 45258249ce..32a4c12eb1 100644 --- a/spec/airport_spec.rb +++ b/spec/airport_spec.rb @@ -1,8 +1,13 @@ require './docs/airport_challenge' + describe Airport do - it 'can create an instance of airport' do + it 'creates instance of airport' do airport = Airport.new expect(airport).to be_kind_of(Airport) end + it 'allows plane to land' do + airport = Airport.new + expect(airport).to respond_to :land + end end From 8efe7aef7e5a545031910041786419d032e15c99 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 03:51:45 +0100 Subject: [PATCH 08/14] added land method --- docs/airport_challenge.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index 8c7d8f6055..9de6cef4ff 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -1,7 +1,9 @@ class Airport - + def land + + end end class Plane -end \ No newline at end of file +end From 71857c4cdb4e388ee9d409676ab3e18e95e6949f Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 14:54:19 +0100 Subject: [PATCH 09/14] Added Takeoff and at_airport? methods --- docs/airport_challenge.rb | 10 ++++++++-- spec/airport_spec.rb | 14 ++++++++++++-- spec/plane_spec.rb | 13 ++++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index 9de6cef4ff..11d6a2ffe7 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -1,9 +1,15 @@ class Airport - def land + def land(plane) + + end + + def takeoff(plane) end end class Plane - + def at_airport? + false + end end diff --git a/spec/airport_spec.rb b/spec/airport_spec.rb index 32a4c12eb1..345a3a50f5 100644 --- a/spec/airport_spec.rb +++ b/spec/airport_spec.rb @@ -6,8 +6,18 @@ expect(airport).to be_kind_of(Airport) end - it 'allows plane to land' do + # it 'allows plane to land' do + # airport = Airport.new + # expect(airport).to respond_to :land + # end + + it 'land takes 1 argument' do airport = Airport.new - expect(airport).to respond_to :land + expect(airport).to respond_to(:land).with(1).argument end + + it "allows a plane to takeoff from airport" do + airport = Airport.new + expect(airport).to respond_to(:takeoff).with(1).argument + end end diff --git a/spec/plane_spec.rb b/spec/plane_spec.rb index 91d1326050..5ee40c93d6 100644 --- a/spec/plane_spec.rb +++ b/spec/plane_spec.rb @@ -1,7 +1,14 @@ -describe Plane do +require './docs/airport_challenge' +describe Plane do it 'creates instance of plane' do plane = Plane.new - expect(plane).to be_kind_of(airport) + expect(plane).to be_kind_of(Plane) + end + + it 'show that plane is no longer at airport' do + plane = Plane.new + plane.at_airport? + expect(plane.at_airport?).to be false end -end \ No newline at end of file +end From 5585cdff8f1cd8da718e1b51f432ae840f305d88 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sat, 23 Apr 2022 17:08:48 +0100 Subject: [PATCH 10/14] added initializer, planes array & fullairport test --- docs/airport_challenge.rb | 9 ++++++++- spec/airport_spec.rb | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index 11d6a2ffe7..a7df08253a 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -1,6 +1,13 @@ class Airport + def initialize(capacity) + @capacity = capacity + @planes = [] + end + def land(plane) - + max_capacity = 10 + raise 'Airport is full, cannot land plane' if @planes.size >= max_capacity + @planes.push(plane) end def takeoff(plane) diff --git a/spec/airport_spec.rb b/spec/airport_spec.rb index 345a3a50f5..efcd5a808e 100644 --- a/spec/airport_spec.rb +++ b/spec/airport_spec.rb @@ -2,7 +2,7 @@ describe Airport do it 'creates instance of airport' do - airport = Airport.new + airport = Airport.new(10) expect(airport).to be_kind_of(Airport) end @@ -10,14 +10,24 @@ # airport = Airport.new # expect(airport).to respond_to :land # end + # not needed as it is fully covered by a future test it 'land takes 1 argument' do - airport = Airport.new + airport = Airport.new(10) expect(airport).to respond_to(:land).with(1).argument end - it "allows a plane to takeoff from airport" do - airport = Airport.new + it 'allows a plane to takeoff from airport' do + airport = Airport.new(10) expect(airport).to respond_to(:takeoff).with(1).argument end + + it 'raises error when landing at full airport' do + airport = Airport.new(10) + plane = Plane.new + 10.times do + airport.land(plane) + end + expect { airport.land(plane) }.to raise_error 'Airport is full, cannot land plane' + end end From d6d12882031abbf5427a9f466891df1ec3f7f283 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Sun, 24 Apr 2022 23:13:35 +0100 Subject: [PATCH 11/14] Added capacity_full & Refactor --- docs/airport_challenge.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index a7df08253a..de30daf706 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -5,14 +5,20 @@ def initialize(capacity) end def land(plane) - max_capacity = 10 - raise 'Airport is full, cannot land plane' if @planes.size >= max_capacity - @planes.push(plane) + raise 'Airport is full, cannot land plane' if capacity_full? + @planes << (plane) end - def takeoff(plane) + def takeoff(plane) + end + + def capacity_full? + max_capacity = 10 + @planes.size >= max_capacity + end + end class Plane From 73fa3b66e631303c51f36d9353b7e4101e08d4e1 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Mon, 25 Apr 2022 01:01:16 +0100 Subject: [PATCH 12/14] Added weather class --- spec/weather_spec | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 spec/weather_spec diff --git a/spec/weather_spec b/spec/weather_spec new file mode 100644 index 0000000000..50f4a32d45 --- /dev/null +++ b/spec/weather_spec @@ -0,0 +1,8 @@ +require './docs/airport_challenge' + +describe weather do + it 'creates instance of weather' do + weather = Weather.new + expect(weather).to be_kind_of(weather) + end +end \ No newline at end of file From 5eb35b24cdd75cafbbdfae991fb199dde4b25af0 Mon Sep 17 00:00:00 2001 From: Sam Button Date: Mon, 25 Apr 2022 01:01:36 +0100 Subject: [PATCH 13/14] final --- docs/airport_challenge.rb | 11 +++-------- docs/plane.rb | 5 +++++ docs/weather.rb | 5 +++++ spec/airport_spec.rb | 2 ++ spec/plane_spec.rb | 3 +++ spec/weather_spec | 8 -------- spec/weather_spec.rb | 23 +++++++++++++++++++++++ 7 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 docs/plane.rb create mode 100644 docs/weather.rb delete mode 100644 spec/weather_spec create mode 100644 spec/weather_spec.rb diff --git a/docs/airport_challenge.rb b/docs/airport_challenge.rb index de30daf706..da549bfee6 100644 --- a/docs/airport_challenge.rb +++ b/docs/airport_challenge.rb @@ -1,4 +1,6 @@ class Airport + attr_reader :plane + def initialize(capacity) @capacity = capacity @planes = [] @@ -8,10 +10,9 @@ def land(plane) raise 'Airport is full, cannot land plane' if capacity_full? @planes << (plane) end - def takeoff(plane) - + raise 'cannot take off, weather is stormy' if stormy? end def capacity_full? @@ -20,9 +21,3 @@ def capacity_full? end end - -class Plane - def at_airport? - false - end -end diff --git a/docs/plane.rb b/docs/plane.rb new file mode 100644 index 0000000000..7c16f58e47 --- /dev/null +++ b/docs/plane.rb @@ -0,0 +1,5 @@ +class Plane + def at_airport? + false + end +end \ No newline at end of file diff --git a/docs/weather.rb b/docs/weather.rb new file mode 100644 index 0000000000..fa2da754f9 --- /dev/null +++ b/docs/weather.rb @@ -0,0 +1,5 @@ +class Weather + def stormy? + true + end +end \ No newline at end of file diff --git a/spec/airport_spec.rb b/spec/airport_spec.rb index efcd5a808e..7dd4935343 100644 --- a/spec/airport_spec.rb +++ b/spec/airport_spec.rb @@ -1,4 +1,6 @@ require './docs/airport_challenge' +require './docs/weather' +require './docs/plane' describe Airport do it 'creates instance of airport' do diff --git a/spec/plane_spec.rb b/spec/plane_spec.rb index 5ee40c93d6..34d3ab0573 100644 --- a/spec/plane_spec.rb +++ b/spec/plane_spec.rb @@ -1,4 +1,6 @@ require './docs/airport_challenge' +require './docs/weather' +require './docs/plane' describe Plane do it 'creates instance of plane' do @@ -11,4 +13,5 @@ plane.at_airport? expect(plane.at_airport?).to be false end + end diff --git a/spec/weather_spec b/spec/weather_spec deleted file mode 100644 index 50f4a32d45..0000000000 --- a/spec/weather_spec +++ /dev/null @@ -1,8 +0,0 @@ -require './docs/airport_challenge' - -describe weather do - it 'creates instance of weather' do - weather = Weather.new - expect(weather).to be_kind_of(weather) - end -end \ No newline at end of file diff --git a/spec/weather_spec.rb b/spec/weather_spec.rb new file mode 100644 index 0000000000..b68fd456e4 --- /dev/null +++ b/spec/weather_spec.rb @@ -0,0 +1,23 @@ +require './docs/airport_challenge' +require './docs/weather' +require './docs/plane' + +describe Weather do + it 'creates instance of weather' do + weather = Weather.new + expect(weather).to be_kind_of(Weather) + end + + it 'weather responds to stormy?' do + weather = Weather.new + expect(weather).to respond_to(:stormy?) + end + + it 'is unable to takeoff if weather is stormy' do + weather = Weather.new + airport = Airport.new(10) + weather.stormy? + expect(airport.takeoff(@plane)).to raise_error 'cannot take off, weather is stormy' + #how to raise error if stormy? is true??? + end +end From 917ae7b561623154c3e2078677801cdeb8717b8d Mon Sep 17 00:00:00 2001 From: Sam Button Date: Mon, 25 Apr 2022 01:07:25 +0100 Subject: [PATCH 14/14] Readme updated --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6dd4fa6bc9..6884c58f20 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ Airport Challenge = ===(_________) ``` +Sam Notes - Unfinished +--------- +I ran out of time to finish the challenge but am also unsure of how/when to use or properly implement attr_readers & doubles. + +I would have written an random number generator with multiple outcomes for different weather options in stormy? then linked this to takeoff and landing. Instructions ---------