From ad23ae33eafd2b5b882d75d83f9d4e6d4b923cb0 Mon Sep 17 00:00:00 2001 From: Osman Bahadir Yilmaz Date: Wed, 15 Feb 2023 23:36:23 +0100 Subject: [PATCH] OsmanBahadir_Solution --- client.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/client.py b/client.py index b177d17..ded0138 100644 --- a/client.py +++ b/client.py @@ -66,21 +66,77 @@ class Premium_Client(Client): def __init__(self, name, surname, balance, loyalty_point, children_number=0, gender='uncertain'): super().__init__(name, surname, balance, children_number, gender) self.loyalty_point = loyalty_point + self.total_loyalty_point=loyalty_point + def add_deposit(self, amount): super().add_deposit(amount) loyalty_point_earned = amount / 10 self.loyalty_point += loyalty_point_earned + self.total_loyalty_point += loyalty_point_earned - if self.loyalty_point > 50: - self.balance += 100 - self.loyalty_point -= 50 - return(f"Congratulations! You've earned {loyalty_point_earned} loyalty points and received a bonus of {amount}. New balance: {self.balance}") + while( self.loyalty_point > 50): + count=self.loyalty_point//50 + self.balance += 100*count + self.loyalty_point -= 50*count + print(f"Congratulations! You've earned {loyalty_point_earned} loyalty points and received a bonus of {100*count} , New balance: {self.balance}") + if self.total_loyalty_point > 1000: + print("Congratulations! now you are a vip member") + self.__class__ = VIP + -pclt = Premium_Client('Danial', 'Melmav', 15000, 0) + -print(pclt.add_deposit(400)) + +class VIP(Client): + def __init__(self, name, surname, balance, loyalty_point, total_loyalty_point,children_number=0, gender='uncertain'): + + print("VIP init") + def add_deposit(self,amount): + + loyalty_point_earned = amount / 10 + + self.loyalty_point += loyalty_point_earned + self.total_loyalty_point += loyalty_point_earned + + while( self.loyalty_point > 50): + count=self.loyalty_point//50 + self.balance += 100*count + self.loyalty_point -= 50*count + print(f"Congratulations! You've earned {loyalty_point_earned} loyalty points and received a bonus of {100*count} , New balance: {self.balance}") + + + level="bronz" + coef=1.01 + if self.total_loyalty_point>2000: + level="silver" + coef=1.02 + if self.total_loyalty_point>3000: + level="gold" + coef=1.03 + self.balance+=amount*coef + Client.total_balance+=amount*coef + return (f'Your balance is updated , {self.balance}. Because of you are a {level} member, you earn extra {amount*(coef-1):.2f} money') + + +pclt = Premium_Client('Danial', 'Melmav', 1500, 120) +clt= Client("john", "smith",7000,3,"man") + +clt2= Client("Jane", "doe", 2000) +pclt2 = Premium_Client('Danial2', 'Melmav2', 15000, 0) +pclt3 = Premium_Client('Danial', 'Melmav', 15000, 0) + +print(pclt.add_deposit(500)) print(pclt.balance) print(pclt.loyalty_point) + +print(pclt.total_loyalty_point) + + + + + + +