-
Notifications
You must be signed in to change notification settings - Fork 64
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
Liam R Airport Challenge Submission #181
Open
liamrisdon
wants to merge
11
commits into
digital-futures-academy:main
Choose a base branch
from
liamrisdon:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
561ad25
domain models created
liamrisdon 5f987bc
first test passed
liamrisdon 0a018be
User Story 2 tests passed
liamrisdon 3feb8a0
User Story 3 tests passed
liamrisdon f7bd5e5
Tests and code refactored for specRunner
liamrisdon 7cc253a
User Story 4 tests passed
liamrisdon 91d2fcb
User Story 5 tests passed
liamrisdon 1b6cece
Extended criteria implemented
liamrisdon 94ef65f
index.js added that runs random weather functionality
liamrisdon 5a5633b
new README created
liamrisdon 1609eb8
final commit
liamrisdon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Airport Challenge | ||
================= | ||
|
||
``` | ||
______ | ||
__\____\___ | ||
= = ==(____DFA____) | ||
\_____\__________________,-~~~~~~~`-.._ | ||
/ o o o o o o o o o o o o o o o o |\_ | ||
`~-.__ __..----..__ ) | ||
`---~~\___________/------------````` | ||
= ===(_________) | ||
|
||
``` | ||
|
||
Instructions | ||
--------- | ||
|
||
* Feel free to use google, your notes, books, etc. but work on your own. | ||
* Keep it SIMPLE - it's not nearly as complicated as it first may look. | ||
* You must [submit your challenge](https://airtable.com/shrUGm2T8TYCFAmjN) by the deadline, wherever you get to. | ||
* Use your own test framework and evidence your test-driven development by committing on passing tests. | ||
* Please write your own README detailing how to install your project, how to run the tests, how you approached the problem and provide screenshots of interacting with your program. | ||
* If you refer to the solution of another coach or student, please put a link to that in your README. | ||
* Please create separate files for every class, module, and spec. | ||
|
||
Steps | ||
------- | ||
|
||
1. Fork this repo, and clone to your local machine | ||
2. `npm install` to install project dependencies | ||
3. Convert stories into a representative domain model and test-drive your work. | ||
4. Run your tests using `npm test` or `node specRunner.js` | ||
5. OPTIONAL: [Lint](https://eslint.org/docs/user-guide/getting-started) your source code using `npx eslint src`. | ||
|
||
Task | ||
----- | ||
|
||
We have a request from a client to write the software to control the flow of planes at an airport. The planes can land and take off provided that the weather is sunny. Occasionally it may be stormy, in which case no planes can land or take off. Here are the user stories that we worked out in collaboration with the client: | ||
|
||
#### Acceptance Criteria | ||
``` | ||
As an air traffic controller | ||
So I can get passengers to a destination | ||
I want to instruct the airport to land a plane | ||
|
||
As the system designer | ||
So that the software can be used for many different airports | ||
I would like a default airport capacity that can be overridden as appropriate | ||
|
||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent landing when the airport is full | ||
|
||
As an air traffic controller | ||
So I can get passengers on the way to their destination | ||
I want to instruct the airport to let a plane take off and confirm that it is no longer in the airport | ||
|
||
As an air traffic controller | ||
To avoid confusion | ||
I want to prevent asking the airport to let planes take-off which are not at the airport, or land a plane that's already landed | ||
``` | ||
|
||
#### Extended Acceptance Criteria | ||
``` | ||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent takeoff when weather is stormy | ||
|
||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent landing when weather is stormy | ||
|
||
As an air traffic controller | ||
To count planes easily | ||
Planes that have landed must be at an airport | ||
``` | ||
|
||
Your task is to test drive the creation of a set of classes/objects to satisfy all the above user stories. You will need to use a random number generator to set the weather (it is normally sunny but on rare occasions it may be stormy). In your tests, you'll need to stub random behaviour to ensure consistent test behaviour. | ||
|
||
Your code should defend against [edge cases](http://programmers.stackexchange.com/questions/125587/what-are-the-difference-between-an-edge-case-a-corner-case-a-base-case-and-a-b) such as inconsistent states of the system ensuring that planes can only take off from airports they are in; planes that are already flying cannot take off and/or be in an airport; planes that are landed cannot land again and must be in an airport, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
# Airport Challenge | ||
|
||
|
||
### User Story 1 | ||
|
||
``` | ||
As an air traffic controller | ||
So I can get passengers to a destination | ||
I want to instruct the airport to land a plane | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ----------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
|
||
#### Tests | ||
1. When `landPlane()` is called `airportPlaneList` increases by 1 | ||
2. `landPlane()` puts the plane with the correct id in `airportPlaneList` | ||
|
||
|
||
### User Story 2 | ||
|
||
``` | ||
As the system designer | ||
So that the software can be used for many different airports | ||
I would like a default airport capacity that can be overridden as appropriate | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------- | -----------------------| --------| | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | | | | ||
|
||
#### Tests | ||
1. There is an `airportCapacity @number` that can be called - default capacity | ||
2. When `modifyAirportCapacity` is called, `airportCapacity @number` changes to expected number. | ||
3. `modifyAirportCapacity` can only change airport capacity to an integer | ||
|
||
|
||
### User Story 3 | ||
|
||
``` | ||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent landing when the airport is full | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ---------------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | isAirportFull() | @Boolean | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
|
||
#### Tests | ||
1. `isAirportFull` returns true if `airportPlaneList` amount is equal to `airportCapacity @number` | ||
2. `isAirportFull` returns false if `airportPlaneList` is less than `airportCapacity @number` | ||
3. If `isAirportFull` is true, then `landPlane(@Plane)` will not modify `airportPlaneList @Array` | ||
4. If `isAirportFull` is true and `landPlane(@Plane)` is called, then an error is thrown. (I anticipate this will require refactoring of test 3) | ||
|
||
### User Story 4 | ||
|
||
``` | ||
As an air traffic controller | ||
So I can get passengers on the way to their destination | ||
I want to instruct the airport to let a plane take off and confirm that it is no longer in the airport | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ---------------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | | takeOff(@Plane) | @Void | | ||
| | | planeInAirport(@Plane) | @Boolean | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | isAirportFull() | @Boolean | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
|
||
#### Tests | ||
1. `takeOff(@Plane)` should remove one plane from `airportPLaneList` | ||
2. `takeOff(@Plane)` should remove a given plane (check id) from `airportPLaneList` - decided to omit | ||
3. `planeInAirport` should return true if that plane is in `airportPLaneList` | ||
4. `planeInAirport` should return false if that plane is not in `airportPlaneList` | ||
|
||
### User Story 5 | ||
|
||
``` | ||
As an air traffic controller | ||
To avoid confusion | ||
I want to prevent asking the airport to let planes take-off which are not at the airport, or land a plane that's already landed | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ---------------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | | takeOff(@Plane) | @Void | | ||
| | | planeInAirport(@Plane) | @Boolean | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | isAirportFull() | @Boolean | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
|
||
#### Tests | ||
|
||
`planeInAirport` functionality was tested in User Story 4 so this modifies `takeOff(@plane)` and `landPlane(@Plane)` to check `planeInAirport`. | ||
|
||
1. If `takeOff(@Plane)` is called but `planeInAirport(@Plane)` returns false, then an error is thrown | ||
2. If `landPlane(@Plane)` is called but `planeInAirport(@Plane)` returns true, then an error is thrown | ||
|
||
### Extended Criteria - User Story 6 & 7 | ||
|
||
``` | ||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent takeoff when weather is stormy | ||
``` | ||
``` | ||
As an air traffic controller | ||
To ensure safety | ||
I want to prevent landing when weather is stormy | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ---------------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | | takeOff(@Plane) | @Void | | ||
| | | planeInAirport(@Plane) | @Boolean | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | isAirportFull() | @Boolean | | ||
| | weatherCondition | isStormy() | @Boolean | | ||
| | | setWeather(@String) | @Void | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
| Weather | weatherStatus | weatherReport() | @String | | ||
|
||
#### Tests | ||
|
||
Thought process: `setWeather` will be used to ensure consistent behaviour for testing - random number generator will be implemented to `Weather` class for randomised weather conditions and used in index.js | ||
|
||
1. Check `setWeather` alters `weatherCondition`. | ||
2. Check `isStormy` returns true when `setWeather` has the parameters of 'stormy'. | ||
3.. Plane does not take off if airport `isStormy` is true. | ||
4. Plane can take off if `isStormy` is false. | ||
5. Plane does not land if `isStormy` is true. | ||
6. Plane can land if `isStormy` is false. | ||
|
||
|
||
|
||
### Extended Criteria - User Story 8 | ||
|
||
``` | ||
As an air traffic controller | ||
To count planes easily | ||
Planes that have landed must be at an airport | ||
``` | ||
|
||
#### Domain Model | ||
| Objects | Properties | Messages | Output | | ||
| ----------- | ------------------------------ | ---------------------- | -------- | | ||
| Airport | airportPlaneList @Array[@Id] | landPlane(@Plane) | @Void | | ||
| | | takeOff(@Plane) | @Void | | ||
| | | planeInAirport(@Plane) | @Boolean | | ||
| | | planeCount() | @number | | ||
| | airportCapacity @number | modifyAirportCapacity()| @Void | | ||
| | | isAirportFull() | @Boolean | | ||
| | weatherCondition | isStormy() | @Boolean | | ||
| | | setWeather(@String) | @Void | | ||
| | | | | | ||
| Plane | id @String | getId() | @String | | ||
| | | | | | ||
| Weather | weatherStatus | weatherReport() | @String | | ||
|
||
#### Tests | ||
|
||
Thought process: Trying to land a plane without defining an airport or to an airport that does not exist will return an error. Functionality of landing and taking off planes has been tested above - so planes in an airport will be stored in [given airport].airportPlaneList. Therefore can then test and create function that counts the number of planes in a given airport for the air traffic controller. | ||
|
||
1. `planeCount()` will return the correct number of planes in an airport. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Domain modelling and planning was clear and well done