Last active
          March 22, 2019 19:14 
        
      - 
      
 - 
        
Save berinhard/e88269e696bd664d290e117308c536a0 to your computer and use it in GitHub Desktop.  
    Paperboy 002
  
        
  
    
      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
    
  
  
    
  | class Wallet: | |
| def __init__(self, money): | |
| self.money = money | |
| def subtract(self, amount): | |
| self.money -= amount | |
| def add(self, amount): | |
| self.money += amount | |
| class Customer: | |
| def __init__(self, name, wallet): | |
| self.name = name | |
| self.wallet = wallet | |
| def pay_for_something(self, payment): | |
| if self.wallet: | |
| if self.wallet.money >= payment: | |
| self.wallet.subtract(payment) | |
| return payment | |
| return 0 | |
| class Paperboy: | |
| def __init__(self, num_of_papers, newspaper_price): | |
| self.num_of_papers = num_of_papers | |
| self.newspaper_price = newspaper_price | |
| def deliver_paper(self, customer): | |
| self.num_of_papers -= 1 | |
| payment = customer.pay_for_something(self.newspaper_price) | |
| if payment == self.newspaper_price: | |
| print("Thanks!") | |
| else: | |
| print("Show me the money!!!") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment