diff_months: 22

Programming in Python using classes and objects Assessment

Download Solution Now
Added on: 2022-10-12 05:27:39
Order Code: 470032
Question Task Id: 0
  • Country :



  1. Class Customer

All customers have a unique ID and name. All existing customers are offered discounts. You

are required to write the class named Customer to support the following:

(i) Attributes ID and name

(ii) Constructor taking the value for ID and name as arguments

(iii) Appropriate getter/accessor methods for the attributes of this class.

(iv) A method get_discount(self, price) which should be an empty super method.


  1. Class Product

This class is to keep track of information of different products in the warehouse. This class

supports the following information.

  • ID – A unique identifier for the product (e.g. “P123”)
  • Name – The name of the product which is always a single word.
  • Price – The price of the product.
  • Stock – The quantity of the product available in stock.

You need to define the appropriate variables and methods to support class Product. Note the

quantity in stock obviously will change. The price of a product may also be changed by the

user (a shop staff member).


  1. Class Order

This class is to handle customer orders. This class supports the following information of an


  • Customer – who made the order (should you use ID, name or something else?)
  • Product – what has been ordered (how about this? Should you use ID or name?)
  • Quantity – The quantity of the product ordered by the customer.

This class can update information in the corresponding customer and product if necessary (be

careful with your overall class design). Define the appropriate variables and methods to support

the Order class.

You may need to find a way to manage an order containing multiple products, e.g. one person

ordered several items in one order. It is up to you how that can be handled. You need to

explain your approach as a part of the documentation.


  1. Class Records

This class is the central data repository of your program. It supports the following information:

  • a list of existing customers
  • a list of exiting products

This class has a method readCustomers, which can read a comma separated file (CSV)

called “customers.txt”. See example below.

C1, Bryan,,,

C2, Zoran,,,

C3, Linda,,,

C4, Jack,,,

Customers are always in this format: ID, Name. There are three more fields reserved for

later parts. For this stage, these fields are empty. Customer IDs always start with letter C.

Assume there is never error in this file.

This class has another method readProducts that can read another CSV file called

“products.txt” and add the products stored in that file to the product list. See the example.

P1, Wine, 10.0, 50

P2, Chocolate, 5.00, 100

P3, Candle, 1, 1000

Products at the Pass level are always in this format: ID, Name, Price per Unit, In-

stock Quantity. Their IDs always start with letter P.

Assume there are no errors in “products.txt”.

This class has two methods findCustomer and findProduct. They are to search through

the lists to find out whether a given customer or a given product exists or not. If found, the

corresponding customer or product will be returned. Otherwise, None will be returned. Note

both customer and product can be searched by either ID or name.

This class also has methods listCustomers and listProducts. They can list all the

customers and products on screen. The display format is the same as that in the text files

shown above. These methods can be used to validate the reading from “customers.txt” and



This can be treated as the main class of you program. It supports a menu and can do the


  1. When your program starts, it looks for “customers.txt” and “products.txt” in the

local directory. If found, data will be read into the program accordingly. The program will

display the menu. Error handling must be in place for file handling. If file reading is not

successful, the program will quit gracefully with an error message.

  1. From the menu, the user can list all customers and list all products. The display format is

the same as that specified in Records.

  1. Your program will allow the user to manually enter an order. You can assume no error in

input at this level. So you don’t have to handle errors.

  1. The total price of the order can be displayed as a formatted message to the user. Note

appropriate discount should apply.

purchased x

Unit price:

Total price:

  1. After making an order, the user can list the product information to see the reduction in the

stock quantity of that product.

  1. When a task is accomplished, the menu will appear again for the next task. The program

always exits gracefully from the menu, e.g. there is an exit option on the menu.

  • Uploaded By : Katthy Wills
  • Posted on : October 12th, 2022
  • Downloads : 0
  • Views : 181

Download Solution Now

Can't find what you're looking for?

Whatsapp Tap to ChatGet instant assistance

Choose a Plan


80 USD
  • All in Gold, plus:
  • 30-minute live one-to-one session with an expert
    • Understanding Marking Rubric
    • Understanding task requirements
    • Structuring & Formatting
    • Referencing & Citing


30 50 USD
  • Get the Full Used Solution
    (Solution is already submitted and 100% plagiarised.
    Can only be used for reference purposes)
Save 33%


20 USD
  • Journals
  • Peer-Reviewed Articles
  • Books
  • Various other Data Sources – ProQuest, Informit, Scopus, Academic Search Complete, EBSCO, Exerpta Medica Database, and more