Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write code in python and answer every part. Write a python code for the following: Level 1 : ( Pass level ) : Class Customers:
Write code in python and answer every part.
Write a python code for the following:
Level : Pass level:
Class Customers:
Write a class named customer and add the following:
a Each customer has a unique ID
b unique name a name will only contain alphabet characters
c Each customer also has some reward points.
d This class named customer also support the following functions:
Attributes ID name, and reward
Constructor takes the values of ID name, and reward as arguments
Appropriate getter methods for the attributes of this class
A method getreward which should be an empty super method
A method getdiscount which should be an empty super method
A method updatereward which should be an empty super method
A method displayinfo which should be an empty super method
Class BasicCustomers:
Write a class named BasicCustomers and add the following:
a All Basic customers have a flat reward rate when making a purchase ie all Basic customers have the same reward rate
b By default, the flat reward rate is
c This class named BasicCustomer should have the following components:
An attribute for the reward rate.
Constructor takes the appropriate parametersarguments
Appropriate getter methods for the attributes of this class
A method getreward which takes the total cost and returns the reward. Note, the reward is always rounded. For example, when the total cost is and the reward rate is then the method will returns the reward which is round x
A method updatereward which takes a value and increase the attribute reward with that value.
A method displayinfo that prints the values of the BasicCustomer attributes.
A method setrewardrate to adjust the reward rate. This method affects all Basic customers.
Class VIPCustomer:Write a class named VIPCustomer and add the following:
a A VIP customer not just receives the reward but also gets a discount for the purchase.
b The reward rate is the same for all VIP customers and has the default value of
c On the other hand, the discount rate is different among VIP customers.
d If not specified, the discount rate is set as
e Note that the reward is computed after the discount. For example, with a reward rate of and discount rate of if a VIP customer makes a purchase with the original total cost of $ then discount will be x $ the total cost after the discount is $ and thus, the a reward is round x
f This class named VIPCustomer should have the following components:
Appropriate attributes to support the reward rate and discount rate
Constructor takes the appropriate parametersarguments
Appropriate getter methods for the attributes of this class
A method getdiscount which takes the total cost and returns the discount offered
A method getreward which takes the total cost and returns the reward
A method updatereward which takes a value and increase the attribute reward with that value.
A method displayinfo that prints the values of the VIPCustomer attributes
A method setrewardrate to adjust the reward rate. This method affects all VIP customers.
A method setdiscountrate to adjust the discount rate of each individual VIP customer.
Class Products:
a This class is to keep track of information on different products that the pharmacy offers.
b This class supports the following information:
ID: a unique identifier of the product.
name: the name of the product you can assume the product names are unique and they do not include any digit
price: the unit price of the product
A method displayinfo that prints the values of the Product attributes
Stock Quantity: An integer representing the current stock level of the product with isinstockmethod: Quickly checks stock availability.
Class Order:
a This class is to store a customer's purchase information.
b This class supports the following information of an order:
customer: the one who makes the purchase can be a Basic or VIP customer Use customer ID to differentiate between the customer while making a purchase whether it is a basic customer or VIP customer.
product: the product of the purchase. Use Product ID
quantity: the quantity of the product ordered by the customer
A method computecost that returns the original total cost the cost before the discount the discount, the final total cost the cost after the discount and the reward. For example, if the original total cost of an order of the customer Tom VIP customer with reward rate of and discount rate of is then this method will return
A method to update the stock quantity of the product when an order is placed.
Unique Order ID: Add an attribute for a unique order ID A method to update the stock quantity of the product when an order is placed.
Unique Order ID: Add an attribute for a unique order ID
Question is Continued in the images.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started