def getValues(): check = True name = "" pay = 0.0 worked = 0 counter = 0 while (check): try: name = str(input("What is your name?\n")) pay = Decimal(input("How much do you make per hour?\n")) worked = int(input("How many hours do you work each week?\n")) check = False except: print("One of your values was invalid please try again.") person = Person(name, pay, worked) check = True while (check): try: person = Person(name, pay, worked) check = False return person except: print("Something went wrong making your profile.") counter += 1 if (counter > 9): print("\n\nProblem could not be resolved. Closing application") time.sleep(3) sys.exit(0)
def parseFile(filename): file = open(filename, "r") lines = file.readlines() numberTables = int(lines[0]) tablesSize = int(lines[1]) length = len(lines) people = [Person()] * (length - 2) tables = [Table()] * (numberTables) for x in range(2, length): splitedSemiColumn = lines[x].split(':') name = splitedSemiColumn[0] caracteristics = splitedSemiColumn[1].split('-') age = caracteristics[0] group = caracteristics[1] hobbie = caracteristics[2] family = caracteristics[3] job = caracteristics[4] interest = caracteristics[5] person = Person(x - 1, name, age, group, hobbie, family, job, interest) people[x - 2] = person for y in range(0, numberTables): table = Table(y, tablesSize) tables[y] = table file.close() return people, tables
def __init__(self, groupSize, startFloor, amntFlrs): self.waiting = [] # mensen die wachten in de lift. self.arrived = [] # mensen die uit de lift zijn gestapt. #Creer Person objects en voeg ze toe in "waiting". for i in range(groupSize): person = Person(startFloor, amntFlrs) self.waiting.append(person)
def generatePop(tables, people): peopleCopy = people[:] tablesCopy = copy.deepcopy(tables) shuffle(peopleCopy) for x in range(0, len(tablesCopy)): size = tablesCopy[x].size if(size >= len(peopleCopy)): p = [Person()]*(len(peopleCopy)) for y in range(0 , len(peopleCopy)): p[y] = peopleCopy.pop(0) tablesCopy[x].setPeople(p) else: p = [Person()]*(size) for y in range(0, size): p[y] = peopleCopy.pop(0) tablesCopy[x].setPeople(p) return tablesCopy
def newBooking(self, flightNumber): flightNumber = self.checkRegisteredFlight(flightNumber) flight = self.getFlightByNumber(flightNumber) if isinstance(flight, (CommercialFlight, CharterFlight)): name = input('Insira o nome do passageiro: ') cpf = input('Insira o CPF do passageiro: ') person = Person(name, cpf) flight.bookPassage(person) passenger = Passenger(person, flight) self.passengers.append(passenger) elif isinstance(flight, TransportFlight): weight = float(input('Digite o peso da sua carga: ')) flight.bookPassage(weight)
quantity=3) grenade = Item(name="Grenade", item_type="explosive", description="Deals 500 damage", value=500, quantity=2) player_items = [ small_hp_potion, medium_hp_potion, large_hp_potion, super_elixer, mega_elixer, grenade ] # Create Some Players and Enemies player1 = Person(name="Belgy", hp=1500, mp=300, defense=100, atk=80, magic=player_magics, items=player_items) player2 = Person(name="Liron", hp=1300, mp=330, defense=100, atk=80, magic=player_magics, items=player_items) player3 = Person(name="Yarin", hp=1400, mp=360, defense=100, atk=90,