submit itec380-01 p2.P
flight(111, roanoke, charlotte, 1159, 1345)which describes flight number 111 between Roanoke and Charlotte which departs at 11:59 a.m. and arrives at 1:45 p.m. Note that times are represented with a 24 hour clock. When using a 24 hour clock, remember to do modulo arithmetic for minutes (i.e. 1159 + 4 = 1203). Remember that // is the integer division operator and that the operator
mod
is also available.
A sample flight information file is available for your use. To use this file, you can either load it in addition to loading your program, or you can incorporate it directly into your program file. If you incorporate it directly, please remove it before submitting your program. You will, of course, want to test your program with more flights than are in this file.
Your program should allow the following 2 queries:
departure(A, B, LeaveTime, FltNum). trip(A, B, LeaveTime, FltList).Query
departure
succeeds if
FltNum
is the number of a flight from
A
to
B
that departs
at or later than LeaveTime
.
Query
trip
succeeds if
FltList
is a list of flights a traveler can take
to travel between A
and B
,
in which the first flight on the list departs from
A
at or after LeaveTime
and in which
all connections allow 30 minutes or more to change planes.
FltList
, then, is an itinerary of flights that will
take a traveler from
A
to
B
, departing from
A
at or after
LeaveTime
.
The cities in FltList
should be unique.
In addition to instantiating FltList, query trip
also prints an itinerary. Thus the results of doing
some sample queries might look like this:
| ?- departure(roanoke, charlotte, 1100, 111). Yes | ?- departure(roanoke, Arrive, 1100, Flight). Arrive = charlotte Flight = 111 | ?- trip(roanoke, elPaso, 900, Flights). Flight 111 - Depart roanoke 1159 - Arrive charlotte 1333 Flight 27 - Depart charlotte 1420 - Arrive dallas 1810 Flight 9999 - Depart dallas 1901 - Arrive elPaso 2020 Flights = [111,27,9999]
To simplify your program, you can have each flight in the database
land on the same day that it takes off,
and you you don't have to look for trips that depart on one day and arrive
on a later day.
You also do not need to consider time zones or DST.
The queries trip
and departure
do NOT have to
be able to instantiate LeaveTime
; this would be quite hard.
Your program should follow good style.
Use white space to make your program easier to understand
and to choose meaningful variable names.
Also include comments to make the code easier to understand
as well as a header comment describing you, the project, etc.
Put your program in a file called flight.P
and
use the command "submit itec380-01 flight.P
"
to turn it in.
Remember that you must be on rucs2 or one of its clients for submit to
work correctly.
Last modified on |