Find an Alternative Landing Time/Location
Break it Down
- Booking reservation at Atlas Cafe
- Has a list of open times for reservation
- Has uncertain drive time to destination (either 20m or 45m)
- If Courtenay, book taxi
- If Smits, book rental
Based on the output from the last problem (which airfield is booked) we will follow one of two different paths.
I might write a case statement to handle the work flow.
Case “Courtenay” will mean we need to book a taxi and set the drive duration to 20 min.
Case “Smits” will mean we need to book a rental and set the drive duration to 45 min.
We’ll use the drive duration along with the estimated flight arrival time to calculate the drive time to Atlas Cafe.
Now that we have an ETA for Atlas, we’ll display bookings relevant to that arrival time, given the provided array of open booking availability.
The user will select their desired booking time and the app will make the reservation.
Variables
let selectedDestination = null; //value obtained from problem 3 let landingTime = somevalue; //time plane lands let driveTime = null; //drive time to Atlas Cafe from any given airport let arrivalTime = null; //arrival at destination let bookThing = null; //either taxi or rental let resTime = null; //reservation time let resAvail = [given array]; //available reservations based on provided information
Functions
//function for booking either a taxi or rental car func book(whereToBook, whatToBook, timeToBookIt){ Case A (whatToBook == “Taxi”) // script: book a taxi for timeToBookIt at whereToBook B (whatToBook == “Rental”) // script: book a rental car for timeToBookIt at whereToBook }; //this function displays reservations available from earliest arrival onward func displayReservations(landingT, driveT){ let earliestArrival = landingT + driveT; /* script: produce a list of clickable reservation bookings based on the earliest arrival time possible, and the remaining available bookings based on the provided array */ }; //on click of one of the items from the list (available booking times) makes booking func bookIt(date, time){ /* script: make the booking at Atlas Cafe based on the date/time provided from click event */ };
Main Script
//based on 0203, either Smits or Courtenay will be stored value Case { A (selectedDestination == "Courtenay") driveTime = 20; bookThing = "Taxi"; B (selectedDestination == "Smits") driveTime = 45; bookThing = "Rental"; }; //book either taxi or rental for location for time of landing book(selectedDestination, bookThing, landingTime); //display list of reservations available starting from earliest possible arrival displayReservations(landingTime, driveTime); //on selection of displayed reservation times bookIt({{date}}, {{time}});
Flowchart
mwilson
Here is my version: https://docs.google.com/document/d/1Mv4ZhDj3SjXL3M5hE1gY2XjY9Kb_1EUrU0-dg3abN14/edit?usp=sharing
roga
I definitely misread the instruction on the last one there – I was adding time as drive time, not landing time. That’s my mistake.