Skip to content

Commit

Permalink
refactored to get rid of the magic number for capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhodine-orleans-lindsay committed Jan 31, 2020
1 parent e2a3d7c commit 454a64b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion JavaScriptAirport/spec/airportSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Airport', function(){
});

it('sets default capacity', function(){
expect(airport.capacity).toEqual(20)
expect(airport.DEFAULT_CAPACITY).toEqual(20)
});

it('raises an error if full', function(){
Expand Down
6 changes: 5 additions & 1 deletion JavaScriptAirport/src/airport.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict'
class Airport{
constructor(){
this.DEFAULT_CAPACITY = 20;
this._runway = [];
this.capacity = 20;
this.capacity = this.DEFAULT_CAPACITY;
};

planes(){
Expand All @@ -16,6 +17,9 @@ class Airport{
this._runway.push(plane);
};
clearForTakeoff(plane){
if(this._runway.length == 0){
throw new Error("Airport Empty!");
}
this._runway.pop(plane);
}
};
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Finally, don’t overcomplicate things. This task isn’t as hard as it may seem
* Finally, please submit a pull request before Monday at 9am with your solution or partial solution. However much or little amount of code you wrote please please please submit a pull request before Monday at 9am.
***Stories Completed(JavaScript)***
User story 1 - User story 1 complete. I initially tried to create the function airport.land(plane) which seemed to be working until the point where I had to push the plane into the array, so I refactored my tests to follow the walkthrough more closely and have the land function in the Plane class.
User story 1 - User story 1 complete. I initially tried to create the function airport.land(plane) which seemed to be working until the point where I had to push the plane into the array, so I refactored my tests to follow the walkthrough more closely and have the land function in the Plane class.
User story 2 -
User story 2 and 3 - User story 2 and 3 complete . I implemented the same method for takeoff as I did for landing in User story 1 but in the plane class included 'this_location' which was assigned to 'airport' I also added some more tests for an error to be raised when the airport was full and when it was empty.
Expand Down

0 comments on commit 454a64b

Please sign in to comment.