Пример #1
0
def AirTeller():
    """
    The main loop of the CSAir Automatic Teller Machine

    :return: Print out query result to the screen
    """
    networkDict = ParseJson.parse("CSAir/Data/Input.JSON")
    network = AirNetwork.AirNetwork(networkDict)

    while True:
        print "Welcome to CSAir!"
        userName = raw_input("Please enter your name: ")
        print("\nHello " + userName + ".\n")
        print("You have the following options:")
        print("1. A list of all cities.\n"
              "2. CSAir Service Facts.\n"
              "3. See our network in a browser.\n")

        while True:
            try:
                actionNumberStr = raw_input("What can I do for ya? (Enter the number of "
                          "the action you would like to perform)")
                actionNumber = int(actionNumberStr)
            except:
                print("Your input is not a number.")
            else:
                break

        if actionNumber == 1:
            TellMetros.tellMetros(network)

        elif actionNumber == 2:
            TellFacts.tellFacts(network)

        elif actionNumber == 3:
            TellMap.tellMap(network)
        else:
            print("Please choose from 1, 2 and 3.")
            time.sleep(1)

        satisfaction = raw_input("Are you happy with our service? (Y/N)")
        if satisfaction.upper() == "N":
            print("Customers' feedback is BS anyway.\n\n")
        elif satisfaction.upper() == "Y":
            print("Thanks for choosing CSAir.\n\n")
        else:
            print("You answer Y or N. Geez!\n\n")
        time.sleep(3)
Пример #2
0
def AirTeller():
    """
    The main loop of the CSAir Management Teller Machine

    :return: Print out query result to the screen
    """
    networkDict = ParseJson.parse("CSAir/Data/Input.JSON")
    network = AirNetwork.AirNetwork(networkDict)

    while True:
        print "Welcome to CSAir Management Gateway!"
        staffCode = raw_input("Please enter your staff code: ")
        print("\nHello " + staffCode + ".\n")
        print("You have the following options:")
        print("1. Manage.\n"
              "2. View Network as a customer.\n")

        while True:
            try:
                actionNumberStr = raw_input("What can I do for ya? (Enter the "
                                            "number of the action you would "
                                            "like to perform)")
                actionNumber = int(actionNumberStr)
            except:
                print("Your input is not a number.")
            else:
                break

        if actionNumber == 1:
            ManageNetwork.performAction(network)

        elif actionNumber == 2:
            print("Connecting you to the AirTeller Machine")

        else:
            print("Please choose between 1 and 2.")
            time.sleep(1)

        satisfaction = raw_input("Do you like the current management system? "
                                 "(Y/N)")
        if satisfaction.upper() == "N":
            print("You are fired.\n\n")
        elif satisfaction.upper() == "Y":
            print("Thanks for using CSAir Management Gateway.\n\n")
        else:
            print("You answer Y or N. Geez!\n\n")
        time.sleep(3)
Пример #3
0
    def findCheapestNeighbor(self, network):
        distToSrc = sys.maxint
        cheapestNeighbor = None

        for outArc in self.outArcs:
            cheapNeighbor = network.nodes[outArc.desti]
            if not cheapNeighbor.out and cheapNeighbor.dist < distToSrc:
                cheapestNeighbor = cheapNeighbor
                distToSrc = cheapNeighbor.dist
        return cheapestNeighbor


if __name__ == "__main__":
    from MapLib import ParseJson
    from MapLib import AirNetwork

    networkDict = ParseJson.parse("Data/cmi_hub.JSON")
    network = AirNetwork.AirNetwork(networkDict)

    node_1 = DijkstraNode(network.metros["CMI"].code, network)
    print (node_1.code)
    print (node_1.dist)

    print ("Outbound flights")
    for outArc in node_1.outArcs:
        print outArc

    print ("Inbound flights")
    for inArc in node_1.inArcs:
        print inArc
Пример #4
0

def performAction(network):
    while True:

        print("1. Remove a city\n"
              "2. Remove a route\n"
              "3. Add a city\n"
              "4. Add a route\n"
              "5. Edit a city\n"
              "6. Save progress\n")

        factNumber = raw_input("What would you like to perform?")
        try:
            dispatch[factNumber](network)
        except ValueError:
            print("\nPlease Enter a number between 1 and 6.\n")
            continue

        if ManageHelpers.endTelling():
            return

if __name__ == '__main__':
    from MapLib import ParseJson, AirNetwork


    networkDict = ParseJson.parse("Data/Input.JSON")
    network = AirNetwork.AirNetwork(networkDict)
    saveProgress(network)