Git Product home page Git Product logo

bank-account_python's Introduction

Bank-Account_Python

class Person:

    def __init__(self, name, lastname):
        self.name = name
        self.lastname = lastname


class Client(Person):

    def __init__(self, name, lastname, nr_account, balance=0):
        super().__init__(name, lastname)
        self.nr_account = nr_account
        self.balance = balance

    def __str__(self):
        return f"Client Nº {self.name} {self.lastname}. Balance :${self.balance} in {self.nr_account} account."

    def deposit(self, money):
        self.balance += money
        print("Deposit accepted")

    def withdraw(self, money):
        if self.balance >= money:
            self.balance -= money
            print("Withdraw realized")
        else:
            print("Insufficient funds")


def create_client():
    name_cl = input("Please enter your name: ")
    lastname_cl = input("Please enter your lastname: ")
    nr_account_cl = input("Please enter your account number: ")
    client = Client(name_cl, lastname_cl, nr_account_cl)
    return client


def init():
    my_client = create_client()
    print(my_client)
    option = 0

    while option != 'F':
        print("Choose: Deposit (D), Withdraw (W) or Finish (F)")
        option = input()

        if option == "D":
            to_deposit = int(input("Money to deposit: "))
            my_client.deposit(to_deposit)

        elif option == "W":
            to_withdraw = int(input("Money to withdraw: "))
            my_client.withdraw(to_withdraw)

        print(my_client)

    print("Thank you for using Python Bank")


init()

bank-account_python's People

Contributors

diegopagini avatar

Stargazers

 avatar

Watchers

 avatar  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.