-
Notifications
You must be signed in to change notification settings - Fork 0
/
Real_Worl_OOP.py
71 lines (56 loc) · 1.5 KB
/
Real_Worl_OOP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class Mpesa():
def deposit():
pass
def deposit():
pass
class Mshwari(Mpesa):
def __init__(self):
self.balance = 1000
def deposit(self,deposit):
if type(deposit) == int and deposit !="":
if deposit >= 0:
self.balance += deposit
return self.balance
else:
return 'Invalid Amount'
else:
raise ValueError()
def withdraw(self,amount):
if type(amount) == int and amount != "":
if amount > 0:
if (self.balance-amount) > 0:
if (self.balance -amount) > 1000:
self.balance-=amount
return self.balance
else:
return 'Insufficient funds in Account'
else:
return 'Enter Amount below Actual balance'
else:
return 'Invalid Amount'
else:
raise ValueError()
class CurrentAccount(Mpesa):
def __init__(self):
self.balance = 0
def deposit(self,deposit):
if type(deposit) == int and deposit !="":
if deposit >= 0:
self.balance += deposit
return self.balance
else:
return 'Invalid deposit amount'
else:
raise ValueError()
def withdraw(self,amount):
if type(amount) == int and amount != "":
if amount > 0:
if (self.balance-amount) > 0:
self.balance-=amount
return self.balance
else:
return 'Enter Amount below Actual balance'
else:
return 'Invalid withdraw amount'
else:
raise ValueError()