Find an Alternative Landing Time/Location
Break it Down
- Mary’s flight is delayed to arrive on the island.
- Booked landing time will have to change.
- Write deterministic algorithm to find later landing time in Courtenay, or reroute to Smits Field.
First we’ll need to check on the expected arrival time of the flight. This may be a calculated value.
Next we’ll probably want to see a list of available landing times for the user to select if there happens to be one that works.
Alternatively, I’ll give the user a “default” button so they can book the default landing location instead.
Whatever they click on, a list item or the default button, I’d like to book the landing time at the respective destination.
Variables
flight = { // object that describes details about the flight destination:"Courtenay", //scheduled destination default:"Smits Field", //default landing strip remainingDuration()}; //remaining flight duration courtenayAvailableArrivalTimes = []; // array of remaining arrival times
Functions
func bookArrival(location, time){ //book arrival for location, at time }; func calculateArrivalTime(duration){ return currentTime() + duration; }; func displayArrivals(arrivalTime){ /* display available arrival times from courtenayAvailableArrivalTimes array that are no earlier than arrivalTime. display as clickable list items. */ }; func select(slot){ //break out location & time variables for bookArrival() func //use bookArrival() func, send courtenay for loc, time for time };
Main Script
//calculate ETA using remaining duration of flight calculateArrivalTime(flight.remainingDuration(); //display available arrival times displayArrivals(calculatedArrivalTime(flight.remainingDuration())); //book arrival using value of booking you click on <li onclick = "select(this.innerText)">{{ date }} {{ time }}</li> //alternatively, click "default" button to default to Smits Field <button onclick = "bookArrival("Smits Feild", calculateArrivalTime(remainingDuration()))" >Default</button>
mwilson
Same issue here.
Start with current time + remaining trip length, compare to available times, if there is a time in Courtenay, land there, otherwise, land in Smit Field.
roga
Yeah, I think the workflow handled this best. I’m not sure my junk pseudo code did it justice. Calculate the time it will take to fly over the destination. Show a list of available landing times from that ETA to ETA + 1h. Display a list. Allow for selection, OR let them click the “default” button and they can reroute to the default airfield (smit).