Last active
December 30, 2015 08:49
-
-
Save yao2030/7804841 to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import random | |
class Customer: | |
def __init__(self, id): | |
self.id = id | |
self.foods = [] | |
self.start = time.time() | |
def choose_foods(self): | |
self.foods = random_choose(5) | |
def total_time(self): | |
return time.time() - self.start | |
def get_foods(self): | |
for i in range(len(self.foods)): | |
def barbecue(self): | |
for i in range(len(self.foods)): | |
def random_choose(n): | |
results = [] | |
for i in range(n): | |
while True: | |
x = random.randint(1, 20) | |
if x not in results: | |
results.append(x) | |
break | |
return results | |
for i in range(5): | |
customer = Customer(i) | |
customer.choose_foods() | |
print customer.total_time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment