Giter VIP home page Giter VIP logo

users_w_bankaccount's Introduction

Assignment: Users with Bank Accounts

Welcome to another Core assignment!

Some students like to explore the assignments before they're finished reading through the lessons, and that's okay! It can be good for your brain to have a preview of what your future challenges might be. However, before you begin this assignment, it's important that you've first:

  • Completed the preceding lesson modules
  • Taken the knowledge checks to confirm your understanding
  • Viewed lecture material related to the assignment topics
  • Completed and submitted your practice assignments

Now, the Assignment:

Create a User class that has an association with the BankAccount class. You should not have to change anything in the BankAccount class.

For example, from the User class we should be able to deposit money into the user's account:

class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email
        self.account = BankAccount(int_rate=0.02, balance=0)

But our User class does not have a self.account_balance attribute. What it does have is an instance of a BankAccount by the name of self.account. That means that we'll be mirroring the methods created in the BankAccount class like make_deposit (and other methods referencing self.account_balance). But we'll be calling on the BankAccount class to do most of the work! That's the goal of this assignment, and you may find that you do not have to add much logic if any.

Remember in our User methods, we can now access the BankAccount class through our self.account attribute, like so:

class User:
    def example\_method(self):
        self.account.deposit(100)		\# we can call the BankAccount instance's methods
    	print(self.account.balance)		\# or access its attributes

Example Display for Sensei bonus

image

  • Create a User class with an __init__ method

  • Add a make_deposit method to the User class that calls on it's bank account's instance methods.

  • Add a make_withdrawal method to the User class that calls on it's bank account's instance methods.

  • Add a display_user_balance method to the User class that displays user's account balance

  • SENSEI BONUS: Allow a user to have multiple accounts; update methods so the user has to specify which account they are withdrawing or depositing to

  • SENPAI BONUS: Add a transfer_money(self, amount, other_user) method to the user class that takes an amount and a different User instance, and transfers money from the user's account into another user's account.

users_w_bankaccount's People

Contributors

andrewt-tran avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.