コード例 #1
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()

# Töltsd fel a fleet példányt olyan módon, hogy a következő legyen a kimenet:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

fleet.add(Thing('Get milk'))
fleet.add(Thing('Remove the obstacles'))
thing2 = Thing('Stand up')
thing2.complete()
fleet.add(thing2)
thing3 = Thing('Eat lunch')
thing3.complete()
fleet.add(thing3)

print(fleet)
コード例 #2
0
from fleet import Fleet
from thing import Thing

getMilk=Thing("Get milk")
getMilk.complete()
removeObs=Thing("Remove the obstacles")
removeObs.complete()
standUp=Thing("Stand up")
eatLunch=Thing("Eat lunch")
fleet = Fleet()
fleet.add(getMilk)
fleet.add(removeObs)
fleet.add(standUp)
fleet.add(eatLunch)
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

print(fleet)
コード例 #3
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

milk = Thing("Get milk")
obstacle = Thing("Remove the obstacles")
stand = Thing("Stand up")
eat = Thing("Eat lunch")

stand.complete()
eat.complete()

fleet.add(milk)
fleet.add(obstacle)
fleet.add(stand)
fleet.add(eat)

print(fleet)
コード例 #4
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()

thing1 = Thing("Get milk")
thing2 = Thing("Remove the obstacles")
thing3 = Thing("Stand up")
thing4 = Thing("Eat lunch")

fleet.add(thing1)
fleet.add(thing2)
fleet.add(thing3)
fleet.add(thing4)

thing3.complete()
thing4.complete()

# - You have the `Thing` class
# - You have the `Fleet` class
# - You have the `fleet_of_things.py` file
# - Download those, use those
# - In the `fleet_of_things` file create a fleet
# - Achieve this output:
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

print(fleet)
コード例 #5
0
ファイル: fleet_feladat.py プロジェクト: nandras88/python
from fleet import Fleet
from thing import Thing

fleet = Fleet()

get_milk = Thing('Get milk')
remove_obstacles = Thing('Remove obstacles')
stand_up = Thing('Stand up')
eat_lunch = Thing('Eat lunch')
stand_up.complete()
eat_lunch.complete()

fleet.add(get_milk)
fleet.add(remove_obstacles)
fleet.add(stand_up)
fleet.add(eat_lunch)

print(fleet)
コード例 #6
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()
fleet.add(Thing("Get milk"))
fleet.add(Thing("Remove the obstacles"))
fleet.add(Thing("Stand up"))
fleet.add(Thing("Eat lunch"))
fleet.things[2].complete()
fleet.things[3].complete()
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch


print(fleet)
コード例 #7
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

fleet.add(Thing('Get milk'))
fleet.add(Thing('Remove the obstacles'))
fleet.add(Thing('Stand up'))
fleet.add(Thing('Eat lunch'))

fleet.things[2].complete()
fleet.things[3].complete()

print(fleet)
コード例 #8
0
def main():

    try:

        jsonDictionary = getVehicleInfo(
        )  # this returns a dictionary with the keys as indicies 0-n and values are vehicle objects
        # with keys vID, vLatitude, vLongitude, fleetID, and vState
        count = 0
        isRunning = True

        try:
            while jsonDictionary[str(count)] != None:
                vehicleObj = jsonDictionary[str(count)]
                vID = vehicleObj["vID"]
                vLat = vehicleObj["vLatitude"]
                vLong = vehicleObj["vLongitude"]
                fleetID = vehicleObj["fleetID"]
                vState = vehicleObj["vState"]
                vLatFloat = float(vLat)
                vLongFloat = float(vLong)
                v1 = Vehicle(ID=vID,
                             latitude=vLatFloat,
                             longitude=vLongFloat,
                             status=vState)  # create new vehicles
                print("New Vehicle created with id ", str(vID))

                if fm.doesIDExist(
                        fleetID
                ):  # if the fleet id is already in the fleet manager
                    fleet = fm.getFleetByID(fleetID)
                    fleet.add(v1)  # add the vehicle to the existing fleet
                    print("Vehicle added to fleet with fleetID: ",
                          str(fleetID))
                else:
                    newFleet = Fleet(
                        fleetID
                    )  # otherwise create a new fleet w/ that fleetID
                    fm.add(newFleet)
                    newFleet.add(v1)
                    print("New fleet created for vehicle with fleetID: ",
                          str(fleetID))

                v1.start()

                count += 1
        except KeyError as e:
            print("Key could not be found.")

        answer = 0
        print("All Vehicles instantiated")
        while isRunning:
            validAnswer = False
            print("What would you like to do?\n1. Exit ")
            try:
                answer = int(input())
                if answer == 1:
                    validAnswer = True
                else:
                    print("Please select '1' if you would like to exit")
            except ValueError as e:
                print("Error: " + str(e))
            if validAnswer:
                isRunning = False
                killAllThreads(fm)
    # the except catches all keyboard exceptions and shuts down the threads
    except KeyboardInterrupt as e:
        isRunning = False
        killAllThreads(fm)
        print("\n^C received,...")
    finally:
        print("Shutting down the vehicle sim...")
コード例 #9
0
# Create a fleet of things to have this output:

list = ["Get milk", "Remove the obstacles", "Stand up", "Eat lunch"]
things = []

for i in list:
    
    if i == "Stand up" or i == "Eat lunch":

        Thing(i).complete()
        things.append(Thing(i))
    else:
        things.append(Thing(i))

for i in things:
    fleet.add(i)
    if i.name == "Stand up" or i.name == "Eat lunch":
        i.complete()
    
print(f'{fleet.__str__}')
        

    
        
fleet
# 1. [ ] Get milk

# 2. [ ] Remove the obstacles

# 3. [x] Stand up
コード例 #10
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()

first = Thing(name='Get milk')
second = Thing(name='Remove the obstacles')
third = Thing(name='Stand up')
fourth = Thing(name='Eat lunch')

third.complete()
fourth.complete()

fleet.add(first)
fleet.add(second)
fleet.add(third)
fleet.add(fourth)

# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

print(fleet)
コード例 #11
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

eat = Thing("Eat fruit")
walk = Thing("Walk")
train = Thing("Train")
sleep = Thing("Sleep")

eat.complete()
walk.complete()

fleet.add(eat)
fleet.add(walk)
fleet.add(train)
fleet.add(sleep)


print(fleet)
コード例 #12
0
from fleet import Fleet
from thing import Thing

fleet = Fleet()
t1 = Thing('Get milk')
t2 = Thing('Remove the obstacles')
t3 = Thing('Stand up')
t4 = Thing('Eat lunch')
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

t3.complete()
t4.complete()
fleet.add(t1)
fleet.add(t2)
fleet.add(t3)
fleet.add(t4)

print(fleet)
コード例 #13
0
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

from fleet import Fleet
from thing import Thing

fleet = Fleet()
things = []
t1 = Thing("Get milk", )
t2 = Thing("remove the obstacles")
t3 = Thing("stand up")
t3.complete()
t4 = Thing("eat lunch")
t4.complete()

things.append(t1)
things.append(t2)
things.append(t3)
things.append(t4)

for thing in things:
    fleet.add(thing)
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

print(fleet)