Exemplo n.º 1
0
from truck import truck

truck_obj = truck(100, 60, 40, 1500, 10)
print(truck_obj.maxload)
print(truck_obj.speedlimit)
print(truck_obj.load())
print(truck_obj.unload())
print(truck_obj.no.of_wheels)
print(truck_obj.speed)
print(truck_obj.weight)
print(truck_obj.mileage)
print(truck_obj.go - forward())
print(truck_obj.reverse())
print(truck_obj.stop)
Exemplo n.º 2
0
def main():
    tStack = Stack()
    userTruck = truck()
    userFinish = False

    while True:
        if userFinish == True:
            break
        userInit = input(
            "Welcome to Wasin's Logistics Arrangement!\nPress 'y' to start stacking items\nPress 'x' to exit\n"
        )
        if userInit.lower() == "y":
            while True:
                if userFinish == True:
                    break
                print("\nSelect a truck to load, input respective number only")
                for elem in userTruck.options:
                    print(str(elem["ID"]) + ")", elem["Size"], elem["Type"])
                userSelectedTruck = input()
                try:
                    userSelectedTruck = int(userSelectedTruck)
                    if userSelectedTruck <= 0 or userSelectedTruck > len(
                            userTruck.options):
                        print("Invalid number")

                    if userSelectedTruck == 1:
                        userTruckSize = userTruck.options[0]["MaxBoxes"]
                        print("\nYou have selected " +
                              userTruck.options[0]["Size"] + " " +
                              userTruck.options[0]["Type"])
                        print("Please note the Truck max stack is : ",
                              userTruckSize)

                        while True:
                            userOptions = input(
                                "\nPress 1 to stack item\npress 2 to remove the top item\nPress 3 to redo\nPress 'x' to finish and exit\n"
                            )

                            if userOptions.lower() == "x":
                                userFinish = True
                                break

                            if int(userOptions) == 1:
                                while True:
                                    if userTruckSize == tStack.size:
                                        print(
                                            "Warning: You have reach maximum stack for this truck, press x to exit, don't try to add more"
                                        )

                                    things = input(
                                        "\nWhat would you like to add? press 'x' to exit\n"
                                    )
                                    if things.lower() == "x":
                                        break
                                    if things.strip() == "":
                                        print("You can't add emptiness..")
                                        continue
                                    if tStack.size >= userTruckSize:
                                        print("Stack overflowed!")
                                        break

                                    tStack.push(things.strip())
                                    print("You have added ", things)
                                    print("Current Stack")
                                    tStack.traverse()

                            if int(userOptions) == 2:
                                try:
                                    tStack.pop()
                                    print(tStack.removedNode.dataValue,
                                          "has been removed")
                                    print("Current Stack")
                                    tStack.traverse()
                                    continue
                                except:
                                    continue

                            if int(userOptions) == 3:
                                tStack.redo()
                                print("Last item has been put back on top")
                                print("Current Stack")
                                tStack.traverse()
                                continue

                    if userSelectedTruck == 2:
                        userTruckSize = userTruck.options[1]["MaxBoxes"]
                        print("\nYou have selected " +
                              userTruck.options[1]["Size"] + " " +
                              userTruck.options[1]["Type"])
                        print("Please note the Truck max stack is : ",
                              userTruckSize)

                        while True:
                            userOptions = input(
                                "\nPress 1 to stack item\npress 2 to remove the top item\nPress 3 to redo\nPress 'x' to finish and exit\n"
                            )

                            if userOptions.lower() == "x":
                                userFinish = True
                                break

                            if int(userOptions) == 1:
                                while True:
                                    if userTruckSize == tStack.size:
                                        print(
                                            "You have reach maximum stack for this truck, press x to exit, don't try to add more"
                                        )

                                    things = input(
                                        "\nWhat would you like to add? press 'x' to exit\n"
                                    )
                                    if things.lower() == "x":
                                        break
                                    if things.strip() == "":
                                        print("You can't add emptiness..")
                                        continue
                                    if tStack.size >= userTruckSize:
                                        print("Stack overflowed!")
                                        break

                                    tStack.push(things.strip())
                                    print("You have added ", things)
                                    print("Current Stack")
                                    tStack.traverse()

                            if int(userOptions) == 2:
                                try:
                                    tStack.pop()
                                    print(tStack.removedNode.dataValue,
                                          "has been removed")
                                    print("Current Stack")
                                    tStack.traverse()
                                    continue
                                except:
                                    continue

                            if int(userOptions) == 3:
                                tStack.redo()
                                print("Last item has been put back on top")
                                print("Current Stack")
                                tStack.traverse()
                                continue

                except ValueError:
                    print("Invalid Input!")
                    continue

        elif userInit.lower() == "x":
            break
        else:
            print("Invalid Input")
            continue

    print("\nStacking summary")
    tStack.traverse()
from car import car
from truck import truck


obj= car("ac","steering_wheel","seat_belt","audio_play")
print(obj.deploy_airbags())

obj1 = truck(100,60,6,40,1500,10,"blue")
print(obj1.load())
print(obj1.unload())
print(obj1.no_of_wheels)
print(obj1.speed)
print(obj1.weight)
print(obj1.mileage)
print(obj1.color)
Exemplo n.º 4
0
from truck import truck

truck_obj = truck(100, 60, 6, 40, 1500, 10, "red")
print(truck_obj.max_load)
print(truck_obj.speed_limit)
print(truck_obj.load)
truck_obj.unload()
truck_obj.stop()
print(truck_obj.no_of_wheels)
Exemplo n.º 5
0
        if firstIteration:
            if value != 0 and value != 0.0 and valueList.index(
                    value) not in visitedLocations:
                currentSmallest = value
                firstIteration = False
        else:
            if value != 0 and value != 0.0:
                if currentSmallest > value:
                    if valueList.index(value) not in visitedLocations:
                        currentSmallest = value
                        indexOfSmallest = int(valueList.index(value))
    return indexOfSmallest


sortedPackages = []
truck1 = truck(1)
truck2 = truck(2)


#sort packages according to delivery order
def packageSort():
    #begin with the packages that have deadlines
    for location in visitedLocations:
        for package in deadlinePackages:
            address = ht.retreiveAddress(package)
            index = findNodeIndex(address)
            if index == location and package not in sortedPackages:
                sortedPackages.append(package)
        for package in normalPackages:
            address = ht.retreiveAddress(package)
            index = findNodeIndex(address)
Exemplo n.º 6
0

all_collection_data = read_collection_data(
)  # list of objects of the collection data from Camara de Lisboa
campolide_routes = read_campolide_routes_file(
)  # list with the route codes for campolide
routes_details = read_routes_details(
)  # list of objects with route details for campolide

trucks_campolide = {}
campolide_collection_data_embalagens = []
for data in all_collection_data:
    if data.route in campolide_routes and data.group == 'Embalagens' and \
        (data.route_type == 'Remoção-Selectiva-PaP-Troço'):
        if data.truck_plate not in trucks_campolide:
            trucks_campolide[data.truck_plate] = truck(data.truck_plate,
                                                       data.truck_type)
        campolide_collection_data_embalagens.append(data)

# with open('./data/trucks_available.csv', 'w') as trucks_file:
#     trucks_file.write('Plate;CapacityM3;CapacityKG')
#     trucks_file.write('\n')
#     for truck in trucks_campolide:
#         line = str(trucks_campolide[truck].plate) + ';' + \
#             str(trucks_campolide[truck].capacity) + ';' + \
#             str(trucks_campolide[truck].capacity_kg) + '\n'
#         trucks_file.write(line)

rota_E0714_Int = filter(lambda x: x.route == 'E0714 Int',
                        campolide_collection_data_embalagens)
rota_E0504 = filter(lambda x: x.route == 'E0504',
                    campolide_collection_data_embalagens)