Exemplo n.º 1
0
class CreditCardTestCase(unittest.TestCase):
    def setUp(self):
        self.cc = CreditCard('John Doe', 'JD Bank', '12345', 1000)

    def tearDown(self):
        del self.cc

    def test_credit_card_charge(self):
        self.assertFalse(self.cc.charge(1001),
                         'allowed a charge above the limit')
        self.assertTrue(self.cc.charge(500),
                        'failed to complete a valid charge')
        self.assertEqual(self.cc.get_balance(), 500,
                         'incorrect balance after charge')

    def test_make_credit_card_charge(self):
        self.cc.charge(500)
        self.cc.make_payment(250)
        self.assertEqual(self.cc.get_balance(), 250,
                         'incorrect balance after making payment')
Exemplo n.º 2
0
#         self.side = side

#     def area(self):
#         return self.side * self.side

# class Rectangle(Shape):
#     def __init__(self, name, x, y):
#         super().__init__(name)
#         self.x = x
#         self.y = y

#     def area(self):
#         return self.x * self.y

# if __name__ == "__main__":
#     square = Square("square", 6)
#     print(f"The area of {square.name} is {square.area()}")

#     rectangle = Rectangle("rectangle", 5, 3)
#     print(f"The area of {rectangle.name} is {rectangle.area()}")

from cod import COD
from credit_card import CreditCard

if __name__ == "__main__":
    cod = COD(1000)
    cod.make_payment()

    cc = CreditCard(1000)
    cc.make_payment()