I have added a file
Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March, 2020 Assessment Details and Submission Guidelines Trimester T1 2020 Unit Code BN108 Unit Title Programming for Networking Assessment Type Individual Assessment Title Assignment 2 - OOP Purpose of the assessment (with ULO Mapping) This assignment assesses the basic concepts of programming; students should be able to demonstrate their achievements in the following unit learning outcomes: a. Describe the fundamental principles of object-oriented programming; b. Interpret a user’s needs while dealing with simple program specifications; c. Design a simple class using UML notation; d. Create a simple application based on UML design and the incremental development process of coding, debugging, and testing; e. Apply basic control structures – sequence, repetition, and selection – to program development; f. Produce simple interactive applications. Weight 35% Total Marks 80 marks Word limit Not applicable Due Date Week 11 (2/06/2020) Submission Guidelines • All work must be submitted on Moodle by the due date along with a completed Assignment Cover Page. • The assignment must be in MS Word format, 1.5 spacing, 11-pt Calibri (Body) font and 2 cm margins on all four sides of your page with appropriate section headings. • Reference sources must be cited in the text of the report, and listed appropriately at the end in a reference list using IEEE referencing style. Extension • If an extension of time to submit work is required, a Special Consideration Application must be submitted directly on AMS. You must submit this application three working days prior to the due date of the assignment. Further information is available at: http://www.mit.edu.au/about-mit/institute-publications/policies- procedures-and-guidelines/specialconsiderationdeferment Academic Misconduct • Academic Misconduct is a serious offence. Depending on the seriousness of the case, penalties can vary from a written warning or zero marks to exclusion from the course or rescinding the degree. Students should make themselves familiar with the full policy and procedure available at: http://www.mit.edu.au/about-mit/institute-publications/policies- procedures-and-guidelines/Plagiarism-Academic-Misconduct-Policy- Procedure. For further information, please refer to the Academic Integrity Section in your Unit Description. http://www.mit.edu.au/about http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/special-considerationdeferment http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/Plagiarism-Academic-Misconduct-Policy-Procedure http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/Plagiarism-Academic-Misconduct-Policy-Procedure http://www.mit.edu.au/about-mit/institute-publications/policies-procedures-and-guidelines/Plagiarism-Academic-Misconduct-Policy-Procedure BN108 Programming for Networking P a g e | 2 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 Assignment 2 Title: Programming for a Vending Machine Assignment Description: This assignment will give you practice with interactive programs, if/else statements, list and classes. Problem Description MIT has decided to create a new vending machine. The machine needs to be programmed in Python for its embedded system. This vending machine application must keep records of items in stock. Details of each item shall include "Item ID","Price","Quantity","Item Name". Figure 1: An overview of the Vending Machine and its contents’ description Task Requirements Imagine you have been invited to develop a menu driven python application to manage records of items in stock of the vending machine. Based on the problem description, starter program (code template) has been provided. Investigate the provided starter program. There are 3 scripts (application.py, userFunctions.py, contents.py). Program is executed by loading and running the application.py. Driver function (main) is defined in the appliction.py, which imports userFunctions module (userFunctions.py). userFunctions module (userFunctions.py ) declares all the core functions (add, buy, search, etc) for supporting the Vending Machine. The userFunctions module imports contents module (contents.py). Note: most of these functions, although declared and wired up in the program are not yet implemented. Your task is to implement these functions. There are ten (10) tasks to be completed which are described next within the modules: 1. application.py • Task 1: implement menu for the user to login() by entering their id a. Check if the user is an employee (e) or a student (s). BN108 Programming for Networking P a g e | 3 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 i. If the ID does not belong to either users, prompt ‘invalid id’ and request input again ii. Else continue to Task 2 • Task 2: if the user is a student, show them menuStudent () • Task 3: if the user is a staff member, show them menuStaff () 2. userFunctions.py • Task 4: implement load_vm(): • Task 5: implement add_item(): a. Employee can add new items in the Vending Machine. b. Search for an item with itemID by Implementing search () function: def search(itemID): for i in items: if(i.itemID==itemID): return i c. Employee can add a new content in the items of a vending machine d. Increase the quantity of items in a slot. addingItem.quantity+= quantity Task: Add 4 water bottles in itemID=A2 If slot with itemID is not present then do not proceed Item ID exists. pass this object, add a new water bottle VendingMachine object itemID: "A2" price: $12 itemName: ["Water"] quantity: 1 "A2" $12 ["Water"] 5 itemID is found Insert 4 new Water item in this list by increasing the quantity Search for slot with itemID A2 Figure 2: Framework for how an item can be added. BN108 Programming for Networking P a g e | 4 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 • Task 6: Implement buy_item() Take input from the user for itemID. E.g. User input: A2 has 3 items in the stock with the price $2. You should confirm if the itemID is present. ItemID is the ID for a slot in the machine. Refer to Figure 3. Slot for water bottles is identified by itemID: A2. Figure 3: A sample vending machine with slot for ItemID: A2 a. Display itemPrice to be paid by the user. Implement calculate(price). i. If the user is a student, they will get 20% off on the itemPrice. i.e. if the itemPrice is $10, then the new itemPrice for the student should be $10-(20/100)*10= $8. ii. If the paid amount is equal to item price, display “Successful” on the screen. iii. If the paid amount is more than the remaining item price, calculate change and display the message: “Your change is: $xyz” iv. If the paid amount is less than the item price, display the balance which needs to be paid. v. (BONUS TASK)1 Start a timer of 20 seconds and wait for user input. If time is out, display Task 1. If the balance has been paid within 20 sec. display “Successful” on the screen. b. Remove the item from the list of items- item has been sold. (Hint- the quantity will reduce.) 1(Task 4a. is bonus task. You may skip it and only do 4b). If you use the timer function and let the timer run for 20 second only, followed by displaying main Menu (Task 1), you will be granted 2 extra marks! ☺ BN108 Programming for Networking P a g e | 5 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 • Task 7: Implement disp() to display all the items in the VM • Task 8: Implement quit_vm() to exit the session. 3. contents.py • Task 9: implement the class VendingMachine (itemID, itemPrice, itemName, quantity) i. Draw a UML model of all classes and add it in the report • Task 10: Demonstrate BN108 Programming for Networking P a g e | 6 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 Description of Program functions Program asks user to login and displays a corresponding menu on execution. For students, 3 menu options are available to allow the student to buy, display, and exit program. For employees, 4 menu options are available to allow the employees to buy, add, display and exit the programs. Program functionality and screen output for each of the menu option upon selection by the user are shown: Program menu on execution: User is a staff (menu for staff): User enters e123. Option E2 (Add a new item to an itemID): BN108 Programming for Networking P a g e | 7 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 Option E3 (Display and check if the quantity has changed): Option E1 (Buy an item): Notice that the employee doesn’t get any discount. BN108 Programming for Networking P a g e | 8 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 User is a student (menu for student): user enters s123 Option S1 (buy an item A1): User enters S1. Option S2 (Display): User enters S2. Note that 1 item from A1 has been bought. The quantity is reduced by 1. BN108 Programming for Networking P a g e | 9 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 Option S1 (Buy when the quantity is 0): User enters S1 Option S3 (Exit Program): User enters S3 BN108 Programming for Networking P a g e | 10 Prepared by: Dr Huma Chaudhry Moderated by: Mr Min Gurung March 2020 Marking criteria: Marking criteria is shown in following table. Marks are allocated as follows: Description of criteria Max marks Marks obtained Implementation of Python functions (50 marks) Task 1: Login : design and functionality 5 Task 2: Menu for student: