Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Products: 4 . Class Product This class is to keep track of information on different products that the pharmacy offers. This class supports the following

Products:
4. Class Product
This class is to keep track of information on different products that the pharmacy offers. 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
Extra attributes and methods if you want to define
Orders
5. Class Order
This class is to store a customer's purchase information. This class supports the following
information of an order:
customer: the one who makes the purchase (can be a Basic or VIP customer). You need to think/analyse carefully if this should be an ID, name, or something else.
product: the product of the purchase. You need to think/analyse carefully if this should be an ID, name, or something else.
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).
Extra attributes and methods if you want to define.
Records
6. Class Records
This class is the central data repository of your program. It supports the following information:
a list of existing customers you need to think what you should store in this list
(customer ID, customer name, or something else?)
a list of existing products you need to think about what you should store in this list
(product ID, product name, or something else?)
This class has a method named read_customers. This method takes in a file name and then read and add the customers in this file to the customer list of the class. In the sequel, we call this the customer file. See an example of the customer file below.
In this file, the customers are always in this format: customer_ID, customer_name,
reward rate, discount_rate (if that is a VIP customer), and reward. For example, in the
1st line, the customer_ID is B1, the name is James, the reward rate is 100%, and the
reward point is 20. In the 3rd line, the customer_ID is V3, the name is Tom, the reward
rate is 100%, the discount rate is 8%, and the reward point is 12. A Basic customer has an ID starting with the letter "B" whilst a VIP customer has an ID starting with the letter "V". The numbers in the ID after these characters (B, V) are all unique (i.e.,1,2,3,5... are unique; for example, if there is a customer with the ID of B1, there won't be a customer with the ID of V1). In this part, you can assume there will be no error in this customer file (e.g., the data format is always correct, and the reward and discount values are always valid).
This class has another method named read_products. This method takes in a file name and can read and add the products stored in that file to the product list of the class. In the sequel, we call this the product file. See an example of the product file below. In this file, the products are always in this format: product_ID, product_name,
unit_price. The product ID always starts with the letter "P". The product IDs and names are all unique. You can assume there will be no error in this file (e.g., the data format is always correct, and the values are always valid).
This class also has two methods find_customer and find_product. These methods take in a search value (can be either a name or an ID of a customer or product), search through the list of customers/products and then return the corresponding
customer/product if found or return None if not found.
This class also has two methods list_customers and list_products. These methods can display the information of existing customers and products on screen. The method list_customers will display the customer ID, name, the reward rate, the discount rate (for VIP customers), and the reward. The method list_products will display the product ID, product name, and the unit price. Note the two methods can be used to validate the reading from the two .txt files associated with the customers and products. NOTE you are allowed to add extra attributes and methods in this class if these attributes and methods make your program more efficient.
Operations
7. Class Operations
This can be considered the main class of your program. It supports a menu with the following options:
i. Make a purchase: this option allows users to make a purchase for a customer. Detailed
requirements for this option are below (Requirements v-ix).
ii. Display existing customers: this option can display all the information of all existing customers:
ID, name, reward rate, discount rate (only for VIP customers), and reward.

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

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions