Example #1
0
seller_samsung = Seller(name='samsung', products_list=[galaxy, tv], wallet=800)
seller_xiaomi = Seller(name='xiaomi',
                       products_list=[redmi, robotvac],
                       wallet=500)
seller_huawei = Seller(name='huawei', products_list=[mate, laptop], wallet=600)

# Wait till the simulation ends
print(
    '\nHello! Welcome to the Market ^_^ Transaction in progress. Lets wait...')
try:
    time.sleep(10)
except KeyboardInterrupt:
    pass

# kill seller thread
seller_apple.kill()
seller_samsung.kill()
seller_xiaomi.kill()
seller_huawei.kill()

# Plot the sales and expenditure trends
plot(seller_apple)
plot(seller_samsung)
plot(seller_xiaomi)
plot(seller_huawei)

# print final results of profit of each seller
print('\nResult:\n')
print('Total Profit Apple:', int(sum(seller_apple.my_profit())))
print('Total Profit Samsung:', int(sum(seller_samsung.my_profit())))
print('Total Profit Xiaomi:', int(sum(seller_xiaomi.my_profit())))
Example #2
0
#

# Create a Seller with some budget
seller_apple = Seller(name='apple', product_dict={iphone5: 1470, iphone7: 1500, headphone: 2000}, wallet=1000, dataCenter=dataCenter,
                      email='*****@*****.**')
seller_samsung = Seller(name='samsung', product_dict={galaxy: 1650, note: 1200, headphone: 2000}, wallet=500, dataCenter=dataCenter,
                        email='*****@*****.**')

# Wait till the simulation ends
try:
    time.sleep(ticks)
except KeyboardInterrupt:
    pass

# kill seller thread
seller_apple.kill()
seller_samsung.kill()

Save(seller_apple, object_type='seller')
Save(seller_samsung, object_type='seller')
# Plot the sales and expenditure trends
plot(seller_apple)
plot(seller_samsung)

regression(seller_apple)
regression(seller_samsung)

for product in seller_apple.product_list:
    print('Total Profit Apple ' + product.name + ': ', seller_apple.my_profit(product))
for product in seller_samsung.product_list:
    print('Total Profit Samsung ' + product.name + ': ', seller_samsung.my_profit(product))