Classic Curve Members

Classic Curve Members

Classic Curves is a one of the famous garment stores. They provide membership to their customers. So they want to create an application to store the customer details as well as the details of their Gold and Diamond members.

Classic Curves provides a discount or cashback for every payment made by the customers. Develop a program to implement this scenario.

Create a base class named ‘Member’ with instance member’s(customerId,customerName,emailId) and a constructor to initialize the data member’s

Create a dervied class ‘GoldMember‘ with instance member(discountAmount), which inherits the Members class, and holds all the properties of the Members and method calculateDiscount(purchaseAmount) which should calculate a 10% discount of the purchaseAmount and set the value for discountAmount after discount.

Create a dervied class ‘DiamondMember’ with instance member(discountAmount), which inherits the Members class, and holds all the properties of the Members and method calculateDiscount(purchaseAmount) which should calculate a 20% discount of the purchaseAmount and set the value for discountAmount after discount.

In the Main class get the input of the Member type, Members, and purchaseAmount and display the Member details with discountAmount based on Member type,  

if account type is Gold Member create an object for GoldMember class and using the same calculate the discountAmount and display the details of member.

if account type is Diamond Member create an object for DiamondMember class and using the same calculate the discountAmount and display the details of member.

Note:

Strictly follow the naming conventions for variables and functions as specified in the problem description.

The GoldMember class object should be g_account_obj

The DiamondMember class object should be d_account_obj

All the attribute values should be user inputs and store those values into the variables with the name: 

customeId for storing Member id.

customerName for storing Member name.

emailId for storing Mail id.

purchaseAmount for storing total purchase amount.

Sample Input 1:

1.GoldMembership

2.DiamondMembership

Enter the choice

1

Enter the Details:

Customer Id

A101

Customer Name

John

EmailId

john@gmail.com

Enter the Purchase Amount

2500

Sample Output 1:

Member Details

A101 John john@gmail.com 2250.0

Sample Input 2:

1.GoldMembership

2.DiamondMembership

Enter the choice

2

Enter the Details:

Customer Id

A102

Customer Name

Martin

EmailId

martin@gmail.com

Enter the Purchase Amount

3000

Sample Output 2:

Member Details

A102 martin martin@gmail.com 2400.0

Code :-

class Member:
    def __init__(self,customerId,customerName,emailId):
        self.customerId=customerId
        self.customerName=customerName
        self.emailId=emailId
    
    def get_customerId(self):
        return self.customerId
    def get_customerName(self):
        return self.customerName
    def get_emailId(self):
        return self.emailId
        
class GoldMember(Member):
    def __init__(self,customerId,customerName,emailId,discountAmount=0):
        super().__init__(customerId,customerName,emailId)
        self.discountAmount=discountAmount
    def calculateDiscount(self,purchaseAmount):
        self.discountAmount=purchaseAmount*((100-10)/100)
    
    def get_discountAmount(self):
        return self.discountAmount
    
    def display(self):
        print(self.get_customerId(),self.get_customerName(),self.get_emailId(),self.get_discountAmount())
    
class DiamondMember(Member):
    def __init__(self,customerId,customerName,emailId,discountAmount=0):
        super().__init__(customerId,customerName,emailId)
        self.discountAmount=discountAmount
    def calculateDiscount(self,purchaseAmount):
        self.discountAmount=purchaseAmount*((100-20)/100)
    
    def get_discountAmount(self):
        return self.discountAmount
    
    def display(self):
        print(self.get_customerId(),self.get_customerName(),self.get_emailId(),self.discountAmount)

print("1.GoldMembership\n2.DiamondMembership")
choice=int(input("Enter the choice:\n"))
print("Enter the Details:")
customerId=input("Customer Id\n")
customerName=input("Customer Name\n")
emailId=input("EmailId\n")
purchaseAmount=float(input("Enter the purchase Amount\n"))
print("Member Details")
if choice==1:
    g_account_obj=GoldMember(customerId,customerName,emailId)
    g_account_obj.calculateDiscount(purchaseAmount)
    g_account_obj.display()
elif choice==2:
    d_account_obj=DiamondMember(customerId,customerName,emailId)
    d_account_obj.calculateDiscount(purchaseAmount)
    d_account_obj.display()

Leave a Comment

Your email address will not be published. Required fields are marked *