School of Science, Engineering and Information Technology ITECH1400 – Foundations of Programming – SEM3/18 School of Science, Engineering and Information Technology ITECH1400 - Assignment 1 –...

1 answer below »
do it according to the pdf thank you


School of Science, Engineering and Information Technology ITECH1400 – Foundations of Programming – SEM3/18 School of Science, Engineering and Information Technology ITECH1400 - Assignment 1 – Recycling Machine Due Date: 5pm, Friday of Week 7 This assignment will test your skills in designing and programming applications to specification and is worth 20% of your non-invigilated (type A) marks for this course. This is an INDIVIDUAL ASSIGNMENT – and while you may discuss it with your fellow students, you must not share designs or code or you will be in breach of the university plagiarism rules. This assignment should take you approximately 20 hours to complete. Assignment Overview You are tasked with creating a text-based program for simulating a Recycling Machine using the Python 3 programming language. The assignment is broken up into four main components: 1.) Design and model two classes: RecyclableItem and RecyclingMachine, 2.) Create an activity chart which describes the behaviour of the Recycling Machine system, 3.) Create a computer program that allows a user to enter items that are able to be recycled into a machine. During the process the machine prompts the user for the type of item to be recycled and how many they have to enter. The machine keeps track of the number of each of the different items and keeps track of the total amount to pay the user until they indicate that they are finished. When they stop adding items, print out a receipt and given them the amount of money owing. The receipt should contain the following: a. A list showing how many of each item has deposited and the cost of each item. b. The total amount provided for each item c. The total money received. 4.) Finally, explain and integrate some code into your Recycling Machine program that keeps track of how many items of each type are in the machine, and, if the machine is full, makes deposits of that item type unavailable. You machine should have at least 4 different products, and allow up to 50 of each product. Your submission should consist of one document containing the first two parts of the assignment, and three Python scripts that implement the computer program (recyclingmachine.py, recyclableItem.py and main.py). The main.py script runs the main logic of the program and will use instances of the RecyclingMachine and RecyclableItem classes to simulate depositing into a Recycling Machine. You are provided with a Microsoft Word template to help you complete the first two parts of this assignment. Towards the end of this document you will also be provided with the output of a simulated run of the completed computer program which may help you with this assignment. Assignment Part 1 Details – Class Design Think of a product that you can recycle that you might want to be able to deposit into a Recycling Machine, like maybe an empty soft drink can. Start by listing all the properties of that object that you can think of – try to come up with at least ten general properties of a RecyclableItem and write these down in your Assignment_Part_1_ Microsoft Word document, provided for download in the assessment section of your Moodle shell. Next, use the process of abstraction to cut the number of properties back to only ‘key’ properties – write these down in the next section of your Word document. Take a look at the week 2 lecture slides if you need a reminder on how to go about this. Now, fill in the class diagram for your Item class in the Word document template provided. Your RecyclableItem class does not have to have any methods (i.e. functions) associated with it to perform any actions other than a constructor which takes and set the key properties that you’ve identified. Next we’ll move on to RecyclingMachine class – think about what information the Recycling Machine has to keep track of to allow you to successfully deposit an item to be recycled. There will only really be three key properties that the RecyclingMachine cares about, and the RecyclingMachine class should have the following five methods available: 1) A default constructor that takes no arguments and initialises a new object and its properties, 2) accept_product(), 3) select_product() 4) payout(anAmount) 5) print_receipt(). Fill in the class diagram for the RecyclingMachine class in the Word template, and that’s the first part completed! Assignment Part 2 Details – Activity Flowchart Using either the online website https://draw.io (preferred), or the applications Visio or Powerpoint – create an activity diagram of how the program should operate to successfully enter their money, buy one or more products, provide change and print a receipt for the user. Make sure to use the correct symbols in your diagram for starting, processes, decisions/branches, and ending the process. Although you may be familiar with how a Recycling Machine works, if not then you can always look online Recycling Machine. Don’t worry about taking payment to debit or credit cards, our RecyclingMachine will only provide cash. Once you have completed your activity chart, add it to your assignment template document. Assignment Part 3 Details – Software Implementation You are free to implement the software however you see fit, however the functionality of the software should be able to match the following output. Note that in the below run of the program I have ‘hard-coded’ a small number of RecyclableItem instances so that products which exist can be purchased – in your code you should do the same. Your program does not have to have the facility to add new recyclable items – just define a few and use them as demonstrated below. If the final option of STOP is chosen, the program should print the receipt and ask the user if they want to start again or quit. Example Program Output Balance: $0.0. Please select a product: (Can, Bottle, Paper, Stop): Can How many cans do you have?: 3 Please place 3 cans into machine. Can accepted Can accepted Can accepted You added 3 can(s) for $0.20 each. You have $0.6. Balance: $0.6. Please select a product: (Can, Bottle, Paper): Bottle How many bottles do you have?: 1 Please place 1 bottle into machine. Bottle accepted You added 1 can(s) for $0.50 each. You now have $1.10. Please select a product: (Can, Bottle, Paper): STOP ----- Final Receipt ----- 3 Can(s)$0.6 1 Bottle(s) $1.0 Number of items4 Amount paid:$1.6 Thank you for recycling at FedUni! (N)ext customer, or (Q)uit? q >>> Part 4 – Code Explanation and Use You are provided with the following two functions which you should 1. Analyse to determine what they do & provide documentation comments for, and 2. Incorporate into your final program solution. Wherever there is a # followed by some underscores in the code below, you should write a short comment explaining what the below section of code is doing, and if there is space why it is doing it. Do part 1 of the above in the provided assignment 1 template document, rather than here! # Function to: ___________________________ def get_float(prompt): # ____________________________________ value = float(0.0) # ____________________________________ while True: try: # ____________________________________ value = float(input(prompt)) # ____________________________________ if value < 0.0:="" print("we="" don't="" accept="" negative="" money!")="" continue="" #="" ____________________________________="" break="" #="" ____________________________________="" except="" valueerror:="" return="" 0.0="" #="" ____________________________________="" return="" value="" #="" function="" to:="" ___________________________="" def="" run():="" #="" ____________________________________="" vm="RecyclingMachine()" #="" ____________________________________="" next_customer="True" #="" ____________________________________="" while="" next_customer:="" #="" ____________________________________="" vm.accept_product()="" #="" ____________________________________="" vm.identify_product()="" #="" ____________________________________="" vm.print_receipt()="" #="" ____________________________________="" while="" true:="" #="" ____________________________________="" answer="get_str("(N)ext" customer,="" or="" (q)uit?")="" #="" ____________________________________="" answer="answer.upper()" #="" ____________________________________="" if="" answer="=" "n":="" #="" ____________________________________="" break="" elif="" answer="=" "q":="" #="" ____________________________________="" exit()="" else:="" #="" ____________________________________="" print("invalid="" response")="" submission="" and="" marking="" process="" you="" must="" supply="" your="" program="" source="" code="" files="" and="" your="" document="" containing="" the="" first="" two="" section="" of="" the="" assignment="" as="" a="" single="" compressed="" archive="" called:="">_.zip Obviously replace and
Answered Same DayJan 09, 2021ITECH1400

Answer To: School of Science, Engineering and Information Technology ITECH1400 – Foundations of Programming –...

Ximi answered on Jan 12 2021
149 Votes
4/.DS_Store
__MACOSX/4/._.DS_Store
4/1/recyclingmachine.py
from recyclableItem import RecyclableItem
class RecyclingMachine(object):
"""
Class Implementation of Recycling Machine
"""
#Constructor
def __init__(self):
self.weight_list = {
"can": 0.10,
"bottle": 0.20,
"paper": 0.02,
"bag": 0.02,
}
self.total_balance = 0
self.items = []
def select_product(self):
"""
Function to display menu to the customer
"""
while True:
name = input("Please select a product: (Bag, Bottle, Paper, Can, Stop) ".\
format(self.total_balance))
if name.lower() == "stop":
break
else:

quantity = int(input("How many %s do you have? "%name))
print ("Please place {} {} into the machine".format(quantity, name))

self.items.append(RecyclableItem(name, quantity))
print ("{} Added".format(name))

def accept_product(self):
"""
Function to accept items
"""
self.sel
ect_product()

def identify_product(self):
"""
Function to identify items which are accepted
"""
i = 0
while i < len(self.items):
if self.items[i].name not in self.weight_list.keys():

print ("Item %s cant be recycled."%self.items[i].name)
#Removing items which arent accepted
self.items.pop(i)
else:
#Pricing based on weight and quantity
self.items[i].price = self.weight_list[self.items[i].name.lower()]*self.items[i].quantity
i +=1
def payment(self, amount):
"""
Assuming payment is by cash
"""
def get_float(prompt):
#Accept valid pay
value = float(0.0)
while True:
try:
value = float(input(prompt))
if value < 0.0:
print("We don't accept negative money!")
continue
break
except ValueError:
print('Please enter a valid decimal value.')
return value
cash = get_float("Please put your dollars: ")
print ("You paid ${}. Change: ${}".format(cash, cash-self.total_balance))
def print_receipt(self):
"""
Print receipt and accept payment
"""
print ("\n----- Final Reciept -----\n")
for item in self.items:
print ("{} {}(s) \t {}".format(item.quantity, item.name, item.price))
self.total_balance += item.price
print ("Number of Items: {}".format(len(self.items)))
print ("Total Amount for your items: {}".format(self.total_balance))

print ("Thank you for recycling at FedUni!")
4/1/.DS_Store
__MACOSX/4/1/._.DS_Store
4/1/recyclableItem.py
class RecyclableItem(object):
def __init__(self, name, quantity,weight=0,):
#Constructor
self.name = name
self.weight = weight
self.quantity = quantity
4/1/student1.docx
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
ITECH1400 - Assignment 1 – Supermarket Self-Service Checkout
Student Name:                            Student ID:
Assignment Part 1 Details – Class Design
Insert your list/table of possible RecycleableItem properties here…
RecycleableItem Properties (All)
        Strength
        Toughness
        Odour
        Colour
        Material
        Age
        Appearance
        Weight
        Use
        Price
        Quantity
        Eco friendly
Insert your list/table of key product properties here…
RecycleableItem Properties (Key)
        Weight
        Price
        Use
        Quantity
Complete the class diagram of your final RecycleableItem class here…
RecycleableItem Class Diagram
RecyclableItem
Name: str
Qty: int
Price: float
No methods
RecyclingMachine Class Diagram
Complete the class diagram of your final Recycling class here…
RecyclingMachine
Balance: float
total_items: int
max_items: int
select_product()
accept_product()
payout(amount)
print_receipt()
identify_product()
Assignment Part 2 – Activity Flowchart
Insert your activity flowchart of the recycling machine process here… If your flowchart is large then place it on the following page.
Assignment Part 3 – Software Implementation
Do not place your code here – provide the code as separate .py files submitted with this document.
Assignment Part 4 – Code Explanation and Use
Update the below code to insert comments describing what the code is doing – for each line starting with a hash symbol (#) you should write your code comments after the hash. You may add a second line of comments if you require more space.
# Function to: accept positive integer value
def get_int(prompt):
# set value to 0
value = int(0)
# infinite loop
while True:
try:
# converting user input to integer
value = int(input(prompt))
# checking negative value
if value < 0:
print("We don't accept a negative number of items!")
continue
# out of loop
break
# handling non-int values
except ValueError:
print('Please enter a valid integer value.')
# returns value accepted
return value
# Function to: accept items into machine
def accept_item(item_list):

# initialising variables
item_list = []
non_accepted_items = []
MAX_WEIGHT = 15.0
# looping over item_list
for item in item_list:
# check If item weight more than bag weight
if item.weight > MAX_BAG_WEIGHT:
item_list.remove(item)
non_accepted_items.append(item)
# setting current variables
current_contents = []
current_weight = 0.0
# loop till item_list finishes
while len(item_list) > 0:
# handle item in temp and remove from item_list
temp_item = item _list[0]
item_list.remove(temp_item)
# check if bag’s current weight+ item weight exceeds max weight
if current_weight + temp_item.weight < MAX_WEIGHT:
# appending to bag
current_contents.append(temp_item)
current_weight += temp_item.weight

# append to products when list finishes
if (len(item_list) == 0):
products_item.append(current_contents)

# bag full condition
else:
item_list.append(current_contents)
# reset current variables
current_contents = []
current_weight = 0.0
# loop over bags in machine
for index, bag in enumerate(machine_list):
output = 'Machine ' + str(index + 1) + ' contains: '
# print all items to user
for item in items:
output += item.name + '\t'
print(output, '\n')
# if non accepted items exist
if (len(non_accepted_items) > 0):
output = 'Non-bagged items: '
# print all non-accepted items
for item in non_accepted_items:
output += item + '\t'
print(output,'\n')
Assignment 1 – FedUni Checkout
Student name:     Student ID:
        Part
        Assessment Criteria
        Weight
        Mark
        1a
        Identification of properties of a typical item that can be recycled – RecycleableItem.
        10 * 0.5 = 5 marks
        
        1b
        Application of abstraction to identify key properties of a typical RecycleableItem as well as creation of a suitable Class Diagram.
        4 marks
        
        1c
        Identification of the key properties of a RecyclingMachine as well as creation of a suitable Class Diagram which uses those properties, plus the four method signatures provided.
        4 marks
        
        2
        Creation of an activity flowchart which clearly indicates how the program should operate, using the correct symbols for elements such as start/end points, processes and decisions/branches
        10 marks
        
        3
        Programming of the product checkout simulation so that it:
i) Creates a small number of RecycleableItem instances that may be accepted,
ii) Accepts simulated ‘deposting’ of a RecycleableItem after being identified from a list by the user,
iii) Adds a RecycleableItem to the RecyclingMachine list of products being purchased,
iv) Allows the deposit of multiple items,
v) Provides ‘virtual money’ to pay for those products (you must pay enough to cover the cost of the items checked out), and
vi) Prints a final receipt of the items deposited, along with the number of items and amount for each item, along with the total paid out.
        4 + 4 + 4 + 4 + 4 + 4 = 24 marks.
        i)
ii)
iiI)
iv)
v)
vi)
Total:
        4a
        Analysis and documentation via code comments of the two functions provided.
        (8 * 0.5) + (16 * 0.5) = 12 marks
        
        4b
        Incorporation of the two functions provided into your main submission so that the program does not crash when an illegal money value is provided, and also virtually ‘bags up’ the products purchased.
        2
        
        Overall
        Overall code standard including comments, formatting, variable names
        9
        
        
        Assignment total (out of 70 marks)
        
        
        
        Contribution to grade (out of 20 marks)
        
        
Comments:
CRICOS Provider No. 00103D        Page of
__MACOSX/4/1/._student1.docx
4/1/main.py
from recyclingmachine_ import RecyclingMachine
def run():
vm = RecyclingMachine()
next_customer = True
while next_customer:
vm.accept_product()
vm.identify_product()
vm.return_receipt()
while True:
answer = input("\n(N)ext customer, or (Q)uit?")
answer = answer.upper()
if answer == "N":
    
break
elif answer == "Q":
exit()
else:
print("Invalid Response")
if __name__ == '__main__':
run()
4/4/.DS_Store
__MACOSX/4/4/._.DS_Store
4/4/main 3.py
from recyclingmachine import RecyclingMachine
def run():
vm = RecyclingMachine()
next_customer = True
while next_customer:
vm.select_product()
vm.print_receipt()
while True:
answer = input("\n(N)ext customer, or (Q)uit?")
answer = answer.upper()
if answer == "N":
    
break
elif answer == "Q":
exit()
else:
print("Invalid Response")
if __name__ == '__main__':
run()
__MACOSX/4/4/._main 3.py
4/4/recyclableItem_copy.py
class WaterBottle(object):
def __init__(self, name,quantity,weight=0,):
#Constructor
self.name = name
self.weight = weight
self.quantity = quantity
4/4/student7.docx
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
ITECH1400 - Assignment 1 – Supermarket Self-Service Checkout
Student Name:                            Student ID:
Assignment Part 1 Details – Class Design
Insert your list/table of possible RecycleableItem properties here…
RecycleableItem Properties (All)
        Plasticity
        green
        natural
        Hygenic
        Strong
        Long lasting
        Cost effective
        Quantity
        Weight
        Use case
        reusable
        Price
Insert your list/table of key product properties here…
RecycleableItem Properties (Key)
        quantity
        price
        age
        Weight
Complete the class diagram of your final RecycleableItem class here…
RecycleableItem Class Diagram
RecyclableItem    
Qty:int
Price:float
Nothing
RecyclingMachine Class Diagram
Complete the class diagram of your final Recycling class here…
RecyclingMachine
Balance:float
select_product()
accept_product()
identify_product()
receipt()
Assignment Part 2 – Activity Flowchart
Insert your activity flowchart of the recycling machine process here… If your flowchart is large then place it on the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here