new deal
unknown
python
a year ago
1.0 kB
10
Indexable
import random
class DealMaker:
def __init__(self, name, wealth):
self.name = name
self.wealth = wealth
def negotiate(self, other_party):
offer = random.randint(1, 100)
response = random.randint(1, 100)
if offer > response:
print(f"{self.name} successfully negotiated the deal with {other_party.name}!")
self.wealth += offer
other_party.wealth -= offer
else:
print(f"{other_party.name} rejected {self.name}'s offer.")
def display_wealth(self):
print(f"{self.name}'s current wealth: {self.wealth}")
# Example usage:
if __name__ == "__main__":
# Creating deal makers
jay_gatsby = DealMaker("Jay Gatsby", wealth=1000)
tom_buchanan = DealMaker("Tom Buchanan", wealth=800)
# Simulating deals
for _ in range(3):
jay_gatsby.negotiate(tom_buchanan)
tom_buchanan.negotiate(jay_gatsby)
# Display final wealth
jay_gatsby.display_wealth()
tom_buchanan.display_wealth()
Editor is loading...
Leave a Comment