Let's make some simple objects!
class Customer(object):
"""A customer of ABC Bank with a checking account. Customers have the
following properties:
Attributes:
name: A string representing the customer's name.
balance: A float tracking the current balance of the customer's account.
"""
def __init__(self, name, balance=0.0):
"""Return a Customer object whose name is *name* and starting
balance is *balance*."""
self.name = name
self.balance = balance
def withdraw(self, amount):
"""Return the balance remaining after withdrawing *amount*
dollars."""
if amount > self.balance:
raise RuntimeError('Amount greater than available balance.')
self.balance -= amount
return self.balance
def deposit(self, amount):
"""Return the balance remaining after depositing *amount*
dollars."""
self.balance += amount
return self.balance
Think Python: How to Think Like a Computer Scientist
http://www.greenteapress.com/thinkpython/thinkpython.pdf
-
Use the terminal to add your file to the repository.
- Create a pull request from your fork to the IntroToPython/objects-101 repo.
- At the main screen for your fork, click the large green button with arrows on it next to the branch name.
- Click the large Create Pull Request button and name your pull request.
- Click Create Pull Request one more time.
This process will allow peer review on any incoming work, along with the ability to discuss specific lines on the same page.
Email: [email protected]