-
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
airport challenge upload #180
base: main
Are you sure you want to change the base?
airport challenge upload #180
Conversation
…ocation meant array comparison tests did not account for that property. Location setter was used to change those planes in comparison array effected
… file of index to show real time functionality.
…on was too complicated. Changed location to atAirport with a boolean value
…d to new set atAirport method
…ess then number of planes already grounded at airport
…r is at minimum zero
…apability/functionality
this.atAirport = atAirport; | ||
} | ||
|
||
static checkInputIsAPlaneObject(input) { |
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.
Think this was a good use of static. I could use the method to see if an input was an instance of Plane and since the method was within the Plane class, it keeps it decoupled and encapsulated
} | ||
|
||
setAirportMaxCapacity(newCapacity) { | ||
if (newCapacity >= this.numberOfPlanesAtAirport() && typeof newCapacity === 'number' && newCapacity >= 0) { |
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.
should have made this multi IF statement a separate method call with the three elements within it
|
||
} | ||
|
||
checkPlaneAtAirport(plane) { |
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.
this could possibly be better. Some() is one or more but the first instance of a duplicate should flagged and returned to help performance and execution time, especially if scaling up the program. Also the program should be written in a way that prevents duplicate planes at an airport as much as possible, not just relying on how things perceived to be coded. I used some() because it returned a TRUE or FALSE, and didn't find the other dot notation covered what I wanted.
|
||
if (this.preTakeOffChecks(plane)) { | ||
|
||
this.listOfPlanesAtAirport = this.listOfPlanesAtAirport.filter(findPlanes); |
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.
Think this reverse use of making an array full of plane objects that didn't meet the criteria using filer() was a good approach
@@ -0,0 +1,48 @@ | |||
class Plane { |
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.
I think the overall code is concise, clean and fit for purpose
console.log(`Weather safe for landing/takeOff? ` + Airport.weatherGenerator()); | ||
} | ||
|
||
function isThisAnInstanceOfPlane(input) { |
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.
Maybe should have done a printer class instead of mixing Function based programming with Object Oriented
@@ -0,0 +1,235 @@ | |||
Airport Challenge |
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.
3 general improvements for next project
Try use more/ different dot notation
Implement mocks for tests
stick to doing TDD approach (new for me)
return foundPlane | ||
} else { | ||
plane.setInFlight(true) | ||
} |
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.
} | |
instructToTakeOff2(plane) { | |
if (this.preTakeOffChecks(plane)) { | |
this.listOfPlanesAtAirport = this.listOfPlanesAtAirport.filter(plane=>foundPlane?.getPlaneID() != plane?.getPlaneID()||plane.setInFlight(true)); | |
} |
instructToTakeOff2(plane) {
if (this.preTakeOffChecks(plane)) {
this.listOfPlanesAtAirport = this.listOfPlanesAtAirport.filter((plane)=>{
if (foundPlane?.getPlaneID() != plane?.getPlaneID()) {
return true;
} else {
plane.setInFlight(true)
return false;
}
});
}
No description provided.