{"id":5215,"date":"2024-06-12T17:31:43","date_gmt":"2024-06-12T15:31:43","guid":{"rendered":"https:\/\/oopm.org\/?page_id=5215"},"modified":"2025-01-14T12:56:44","modified_gmt":"2025-01-14T11:56:44","slug":"10-2-2-booking-of-flights","status":"publish","type":"page","link":"https:\/\/oopm.org\/?page_id=5215","title":{"rendered":"10.2.1 Booking of flights"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-page pdfprnt-top-right\"><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages5215&print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/pdf.png\" alt=\"image_pdf\" title=\"View PDF\" \/><\/a><a href=\"https:\/\/oopm.org\/index.php?rest_route=wpv2pages5215&print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\"><img decoding=\"async\" src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">In order to support booking of flights we need that <code>FlightRoute<\/code> is extended with <code>scheduledFlightTime<\/code>, as this one of the criteria people use when booking:<\/p>\n\n\n\n<pre class=\"wp-block-code has-custom-color-1-background-color has-background\"><code><strong>class<\/strong> FlightRoute(flightNumber, origin, destination: <strong>var<\/strong> String):   \n   <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3a3939\" class=\"has-inline-color\">scheduledDepartureTime: <strong>var<\/strong> TimeOfDay \n   scheduledArrivalTime: <strong>var<\/strong> TimeOfDay <\/mark>\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3a3939\" class=\"has-inline-color\">   flights: <strong>obj<\/strong> OrderedList(Flight)<\/mark> \n   <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3a3939\" class=\"has-inline-color\">-<\/mark>\"-<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3a3939\" class=\"has-inline-color\">\n   <\/mark>scheduledFlightTime -&gt; sft: <strong>var<\/strong> Time.Hours:  \n      sft :=  scheduledArrivalTime - scheduledDepartureTime<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Objects of class <code>Flight<\/code> are created as soon as it is possible to make bookings on this flight, typically some months before scheduled departure. At that time the <code>departureDate<\/code> is set. For this purpose, the class <code>FlightRoute<\/code> has the method <code>createFlight<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code has-custom-color-1-background-color has-background\"><code><strong>class<\/strong> FlightRoute(flightNumber, origin, destination: <strong>var<\/strong> String):\n   -:-\n   createFlight(d: <strong>var<\/strong> Date):\n      f: <strong>ref<\/strong> Flight\n      f := Flight(d)\n      f.departureTime := scheduledDepartureTime\n      f.arrivalTime := scheduledArrivalTime\n      flights.insert(f)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Booking is based upon choosing origin and destination airports, together with a date. In practise the airline will provide options for the given date plus\/minus a couple of day; the following simply gives the flights at just one date.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For simplicity we have excluded the handling of seats, but we do that in section <script>mkRef(\"Self-constrained\u00a0virtual class\")<\/script>. Given origin and destination airports, and a date, we define a method <code>flightsForBooking<\/code> that delivers a list of the actual flights. The list delivered by this method will form the basis for a website where the <code>Flight<\/code> information is displayed together with e.g. price, in a form that makes it possible to select one of the flights and reserve seats.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>flightsForBooking(from, to: <strong>var<\/strong> String, d: <strong>var<\/strong> Date) \n      -&gt; flights: <strong>ref<\/strong> OrderedList(Flight):\n   flights := timeTable.flightsFromToAt(from, to, d)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is based on a method <code>flightsFromToAt<\/code> in the <code>timeTable<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeTable: <strong>obj<\/strong>\n   -\"-\n   flightsFromToAt(from, to: <strong>var<\/strong> String, d: <strong>var<\/strong> Date)\n         -&gt; flights: <strong>ref<\/strong> OrderedList(Flight): \n      routesFromTo(from, to).scan\n         current.flights.scan\n            if (current.date = d) :then flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">which in turn is based on a method <code>routesFromTo<\/code>, also in <code>timeTable<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>timeTable: <strong>obj<\/strong>\n   -\"-\n   routesFromTo(from, to: <strong>var<\/strong> String) \n         -&gt; routes: <strong>ref<\/strong> OrderedList(FlightRoute): \n      entries.scan\n         if (current.origin = from and current.destination = to) \n            :then routes.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the call <code>routesFromTo(from, to)<\/code> in <code>flightsFromToAt<\/code> delivers an ordered list of references to <code>FlightRoute<\/code> objects. As an <code>OrderedList<\/code> has a <code>scan<\/code> method, the statement<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   routesFromTo(from, to).scan\n      current.flights.scan\n         if (current.date = d) :then flights.insert(current)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">describes the invocation of a singular method object with <code>routesFromTo(from, to).scan<\/code> as super method. The singular method has one statement which in turn is a singular method with <code>current.flights.scan<\/code> as super method. In the innermost scanning of the <code>flights<\/code> list, each element (<code>current<\/code>), where <code>date = d<\/code>, is inserted in <code>flights<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, in summary, the method <code>route<\/code>s finds all the <code>FlightRoute<\/code> objects that matches the origin\/destination airports and delivers this as a list. For each of the <code>FlightRoute<\/code> objects in this list, scanning the <code>flights<\/code> list finds the list of <code>Flight<\/code> objects with the right departure date.<\/p>\n<div style=\"display:flex; gap:10px;justify-content:center\" class=\"wps-pgfw-pdf-generate-icon__wrapper-frontend\">\n\t\t<a  href=\"https:\/\/oopm.org?action=genpdf&amp;id=5215\" class=\"pgfw-single-pdf-download-button\" ><img src=\"https:\/\/oopm.org\/wp-content\/plugins\/pdf-generator-for-wp\/admin\/src\/images\/PDF_Tray.svg\" title=\"Generate PDF\" style=\"width:auto; height:45px;\"><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>In order to support booking of flights we need that FlightRoute is extended with scheduledFlightTime, as this one of the criteria people use when booking: Objects of class Flight are created as soon as it is possible to make bookings on this flight, typically some months before scheduled departure. At that time the departureDate is [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":5004,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5215","page","type-page","status-publish","hentry"],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5215"}],"version-history":[{"count":38,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5215\/revisions"}],"predecessor-version":[{"id":11117,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5215\/revisions\/11117"}],"up":[{"embeddable":true,"href":"https:\/\/oopm.org\/index.php?rest_route=\/wp\/v2\/pages\/5004"}],"wp:attachment":[{"href":"https:\/\/oopm.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}