-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework.py
More file actions
34 lines (26 loc) · 953 Bytes
/
Homework.py
File metadata and controls
34 lines (26 loc) · 953 Bytes
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
# # Getter and setters :
'''--> create a classs Bankaccount with a private attribute balance:
write a Getter method to retrive the balance and a setter method to update it, ensuring the balance never goes below zero.
'''
class BankAccount:
def __init__(self,balance):
self.__balance = balance
def get_balance(self):
return self.__balance
def set_balance(self,updated_balance):
if updated_balance < 0:
print("balance cannot be a negative values")
return self.__balance
# # Method Overriding
'''--> create a parent class shape with a method draw() that printd "Drawing shape"
create a child class that overrides draw() to print " DrawingCricle".
'''
# class Shape:
# def draw(self):
# print("Drawing shape")
# class circle(Shape):
# def draw(self):
# super().draw()
# print("Drawing Circle")
# C1 = circle()
# C1.draw()