代写IFN581 Assessment 2 - Programming Assignment代做Python编程

IFN581 Assessment 2 - Programming Assignment

Weighting: 40%    Total Marks: 100    Individual

Due Date: 11.59 pm 24th Oct 2025

(Eligible for 48 hours Automatic Extension)

Submission: Online via QUT Canvas: One Submission only

1. You should not use any Python concepts which have not been taught as part of this Unit.

2. Do not use Internet Resources including ChatGPT and AI.

Any breach of these two conditions will be considered as an act of major academic misconduct and could incur severe penalty.

This Programming Assignment is split into three Parts.

All these three parts are to be part of one Python program file with extension .py.

Part A: Define the Product class with category definitions, attributes, getter/setter methods for product_id, a constructor, and a str() method.

Part B: Write functions and a main program to input, validate, display, and filter a list of products using the Product class.

Part C: Implement file operations to save/load products and display them.

Part A: Define a Product Class in Python

You are required to create a Python class named Product that models product information in a retail shop, following these specifications:

1. Define two static lists (class attributes) to represent the valid product categories:

categoryCodes = ["GR", "HB", "CF", "EL", "HL", "OT"]

categoryNames = ["Groceries", "Health & Beauty", "Clothing & Footwear", "Electronics", "Home & Living", "Others"]

2. The Product class must include the following instance attributes:

product_id: a private attribute, string (e.g., "EL101"), accessed via get_product_id() and modified via set_product_id().

category_name_of_product: a read-only attribute, string, derived from the product_id and modified via set_product_id().

product_name: a public attribute, string (e.g., " Bluetooth Speaker").

quantity: a public attribute, integer (number of items in stock).

price: a public attribute, float (unit price).

3. Product ID Validation Logic

Implement getter and setter for product_id. The setter must:

· Extract the first two characters from the given product_id and use them to look up the corresponding category name. There is no need to store the category code as a separate attribute.

· If the code exists in categoryCodes, assign it as-is and set the corresponding category_name_of_product.

· If the code does not exist, automatically change the category code to "OT" (Others) and rewrite the product_id with "OT" followed by the number part.

Examples:

· Input "EL205" → Product ID: EL205, Category: Electronics

· Input "ZZ101" → Product ID rewritten as OT101, Category: Others

4. Constructor (__init__ ()) method: Implement a constructor that allows both default and parameterized instantiation:

def __init__(self, product_id=None, product_name="", quantity=0, price=0.0)

· If no arguments are provided, initialize with default values.

· If arguments are provided, assign them accordingly.

Examples:

· p1 = Product()  # Create a product with default values

· p2 = Product("EL205", "Bluetooth Speaker", 1, 49.99)

5. String Representation (__str__ ()) method:

Override the __str__ method to provide a nicely formatted string output when the product object is printed:

Example output:

Product ID: EL205   |   Category: Electronics   |   Name: Bluetooth Speaker   |   Quantity: 1   |   Price: $49.99

Part B: Program Functions

Write a main program that performs the following tasks using the Product class:

1. display_introduction(): Displays your name, student ID, and a greeting message surrounded by a border. You don’t need to ask user to input these values. For example:

****************************************

* Name: Lara Dev                           *

* Student ID: 12345678                     *

* Hello, welcome to my program!            *

****************************************

2. input_value(min, max):
Prompts for an integer input between min and max (inclusive). Re-prompts until valid.

3. is_valid(product_id):
Returns True if the string is 5 characters long, starts with two uppercase letters, and ends with three digits.

4. get_product_data(n):
Repeatedly prompts user to enter details for n products. Validates each product ID using is_valid() before assigning via set_product_id(). Returns a list of Product objects. When prompting for quantity, restrict the valid range to 1–50 items.

5. display_all_products(products):
Prints details of all products using each product’s __str__() method.

6. get_product_lists(products):
Allows user to filter and view products by category code and shows the total per category.

Part C: File Operations & Dictionary Grouping

1. save_products_to_file(filename, products):
Writes all product records to a file in comma-separated format.

2. load_products_from_file(filename):
Reads from the file and reconstructs Product objects. Returns a list.

3. main() Function Tasks:
Your main() function must execute the following in order:

a. Call display_introduction()
b. Prompt the user for number of products (1–40) using input_value()
c. Call get_product_data() to input product details, using the number obtained in Part C, Task 3.b as the argument.
d. Call display_all_products() to show all entered products
e. Save products to "Student_Surname_Product.txt" using save_products_to_file()
f. Allow the user to repeatedly search for products by category using get_product_lists(), until they enter '!' to stop.
g. Load products back from file using load_products_from_file()
h. Display the loaded products by calling display_all_products().

In completing your assignment, please take note of the following:

· You should develop your code using simple logic.

· Test your code using your own test data covering multiple data sets.

· Your final code should not have any compilation/execution errors.

Project Deliverable:

Program Code

Upload the file with .py extension onto Canvas using IFN581 Assessment 2 Programming Assignment link under Assessment 2 in Modules.

The link will be available only from Monday 20th October 2025.

You can upload only ONCE.

Note:

Assessment submitted after the due date without an approved extension will not be marked and will receive a grade of 1 or 0%. If special circumstances prevent you from meeting the assessment due date, you can apply for an extension through the Student Services in Faculty of Science. If you do not have an approved extension you should submit the work you have completed by the due date and it will be marked against the assessment criteria. Do not send us email requesting for extension.





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图