Answered step by step
Verified Expert Solution
Link Copied!

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 1: (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 get_reward which should be an empty super method
A method get_discount which should be an empty super method
A method update_reward which should be an empty super method
A method display_info 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 (i.e., all Basic customers have the same reward rate),
b. By default, the flat reward rate is 100%,
c. This class named BasicCustomer should have the following components:
An attribute for the reward rate.
Constructor takes the appropriate parameters/arguments.
Appropriate getter methods for the attributes of this class
A method get_reward which takes the total cost and returns the reward. Note, the reward is always rounded. For example, when the total cost is 14.8 and the reward rate is 100%, then the method will returns the reward which is round(14.8 x 100%)=15.
A method update_reward which takes a value and increase the attribute reward with that value.
A method display_info that prints the values of the BasicCustomer attributes.
A method set_reward_rate 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 100%.
c. On the other hand, the discount rate is different among VIP customers.
d. If not specified, the discount rate is set as 8%.
e. Note that the reward is computed after the discount. For example, with a reward rate of 100% and discount rate of 8%, if a VIP customer makes a purchase with the original total cost of 30$, then discount will be 30 x 8%=2.4$, the total cost after the discount is 27.6$, and thus, the a reward is round(27.6 x 100%)=28.
f. This class named VIPCustomer should have the following components:
Appropriate attributes to support the reward rate and discount rate
Constructor takes the appropriate parameters/arguments
Appropriate getter methods for the attributes of this class
A method get_discount which takes the total cost and returns the discount offered
A method get_reward which takes the total cost and returns the reward
A method update_reward which takes a value and increase the attribute reward with that value.
A method display_info that prints the values of the VIPCustomer attributes
A method set_reward_rate to adjust the reward rate. This method affects all VIP customers.
A method set_discount_rate 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 display_info that prints the values of the Product attributes
Stock Quantity: An integer representing the current stock level of the product with is_in_stock(method): 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 compute_cost 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 100% and discount rate of 8%) is 30, then this method will return (30,2.4,27.6,28).
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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

Do you agree that unions stifle creativity? Why or why not?

Answered: 1 week ago

Question

6 What is the selection phase?

Answered: 1 week ago