Pick the Best Route and Means (Air or Ground) to Ship a Package Between Two Cities
////////////////////////////////////////////////////////////////////////////
// Transportation Megaprogram
//
// Joshua Hui
// Meikel Poess
// Catherine Tornabene
//
// March 24, 1997
//
////////////////////////////////////////////////////////////////////////////
// Indicate which megamodules will be used
import "IOMM" // does I/O between megaprogram and user
import "RouteMM" // get all routes between two given cities
import "AirMM" // calculate the cost between two cities by air
import "GroundMM" // calculate the cost between two cities by ground
import "BestRouteMM" // pick the best route, given several routes
Program
{
// bind to the megamodules
ioh = setup ("IOMM");
routeh = setup ("RouteMM");
airh = setup ("AirMM");
groundh = setup ("GroundMM");
bestrouteh = setup ("BestRouteMM");
// get the two desired cities from the megaprogram user
ioph = ioh.invoke ("input");
// wait for the IO megamodule to finish
while (ioph.examine () != DONE) {}
// get all routes between the two cities
routeph = routeh.invoke ("GetRoutes", ioph.OutputString);
// wait for the route megamodule to finish
while (routeph.examine () != DONE) {}
// get all city pairs
routeph = routeh.invoke ("GetCityPairList", routeph.RouteList);
// wait for the route megamodule to finish
while (routeph.examine () != DONE) {}
// calculate the costs of all routes
airph = airh.invoke ("GetCost", routeph.CityPairs);
groundph = groundh.invoke ("GetCost", routeph.CityPairs);
// wait for air, ground megamodules to finish
while (airph.examine () != DONE) {}
while (groundph.examine () != DONE) {}
// pick the best route
bestrouteph = bestrouteh.invoke ("PickBest", groundph.GroundCost,
airph.AirCost,
routeph.RouteList);
// wait for best route megamodule to finish
while (bestrouteph.examine () != DONE) {}
// print out the best route for the megaprogram user
ioph = ioh.invoke ("output", bestrouteph.BestRoute);
}