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

airport challenge upload #180

Open
wants to merge 69 commits into
base: main
Choose a base branch
from

Conversation

DavidKilpatrickUni
Copy link

No description provided.

…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
…ess then number of planes already grounded at airport
this.atAirport = atAirport;
}

static checkInputIsAPlaneObject(input) {
Copy link
Author

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) {
Copy link
Author

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) {
Copy link
Author

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);
Copy link
Author

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 {
Copy link
Author

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) {
Copy link
Author

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
Copy link
Author

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)
}
Copy link

@Wilfrick Wilfrick Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
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;
			}
		});
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants