In: Computer Science
Write a Python class to represent a Salik account. The account has three attributes, a name, id, and the balance. The balance is a private attribute. The class has extra functions to add to the balance and reduce the balance. Both, these functions should return the current balance and if the balance is below AED 50.0 print the message “Note: Balance Below 50”.
Your class must work for the code given below.
#Test
myCar = SalikAccount()
myCar.setName("John")
myCar.setID("190300300333")
myCar.setBal(20.0)
yourCar = SalikAccount("Ahmed", "102003993", 78.5)
myCar.addBalance(500)
yourCar.reduceBalance(40)
****This requires some effort so please drop a like if you are satisfied with the solution****
I have satisfied all the requirements of the question and I'm providing the screenshots of code and output for your reference...
Code:
class SalikAccount():
def __init__(self, name="", id="", balance=0):
self.name = name
self.id = id
self.__balance = balance
def setName(self, name):
self.name = name
def setId(self, id):
self.id = id
def setBal(self, bal):
self.__balance = bal
def getName(self):
return self.name
def getId(self):
return self.id
def getBal(self):
return self.__balance
def addBalance(self, amount):
self.__balance += amount
print("Money added Current Balance =", self.__balance)
def reduceBalance(self, amount):
if amount > self.__balance:
print("Not enough balance reduce amount and try again...")
else:
self.__balance -= amount
if self.__balance < 50:
print("Money reduced current Balance =", self.__balance)
print("Note: Balance below 50")
else:
print("Money reduced current Balance =", self.__balance)
myCar = SalikAccount()
myCar.setName("John")
myCar.setId("190300300333")
myCar.setBal(20.0)
yourCar = SalikAccount("Ahmed", "102003993", 78.5)
myCar.addBalance(500)
yourCar.reduceBalance(40)
Output Screenshot:

Code Screenshots:

