Git Product home page Git Product logo

atm's People

Contributors

sturivny avatar

Watchers

 avatar  avatar

atm's Issues

bug #222 when I twice enter incorrect pin and third correct

Bug #222 in the method test_wrong_two_times_last_right:

def test_wrong_two_times_last_right(self):
    """ two times wrong ,last right 
        1.enter incorrect pin(111)
        2.enter incorrect pin(111)
        3.enter correct pin (777)"""
    try: 
        self.atm.enter_pin(111)
    except IncorrectPin:
        try: 
            self.atm.enter_pin(111)
        except IncorrectPin:
            try:
                self.atm.enter_pin(777) 
            finally:
                self.assertEqual(10000,self.atm.check_balance())

My propose to fix it:

__attempts in the file atm.py should be
__attempts = 3

Get_money(-1) .My propose to fix it

when I try to get_money(-1) and after it check_balance program works incorrect.

from atm import Atm
terminal = Atm()
terminal.enter_pin(777)
True
terminal.get_money(-1)
-1
terminal.check_balance()
10001

I propose to edit code such:
in the atm.py add this code
def get_money(self, money):
"""Method to get some money for sweets from the ATM"""
if self.__client_can_get_money:
if money < 0:
raise MinusGetMoney("Number can't be minus!!!")

        if money <= self.__atm_balance:
            self.__atm_balance = self.__atm_balance - money
            return money
        else:
            raise AtmBalance("Atm balance is no enough!!!")
    raise EnterPin("Enter pin first!!!")

and in atm_exceptions.py add this code:

class MinusGetMoney(Exception):
pass

after this operations the resuls will be correct

from atm import Atm
terminal = Atm()
terminal.enter_pin(777)
True
terminal.get_money(-1)
Traceback (most recent call last):
File "", line 1, in
File "atm.py", line 35, in get_money
raise MinusGetMoney("Number can't be minus!!!")
atm_exceptions.MinusGetMoney: Number can't be minus!!!

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.