productType |
Weight |
Quantiy |
Barcode |
Fees |
ManufacturingDate |
Weight |
|
|
|
|
|
RecycleableItem Properties (Key)
productType |
Quantity |
Fees |
|
Assignment Part 2 – Activity Flowchart
Assignment Part 3 – Software Implementation
Separate python file are provided of the software implementation
Assignment Part 4 – Code Explanation and Use
#import RecyclableItem module
from RecyclableItem import RecyclableItem
class RecyclingMachine:
#List declared to hold all the recycled product
recycledProductList=[]
#List to hold all type of item which can be recycled
productType=['Can', 'Bottle', 'Paper'];
#List to hold the value of each recycled items
productValue=[0.2,0.5, 0.1];
#variable to hold total payout of particular user
totalPayout=0;
#This is the declaration of the constructor to initialize recycled list
def __init__(self):
#Initialize the checked out product list with the empty list
self.recycledProductList=[];
#This is accept the product and add it into the list
def accept_product(self, recyclableItem):
self.recycledProductList.append(recyclableItem);
#This method is to select the particular product in the list and add it into the list
def select_product(self, selectedProduct, quantity):
#get the index of the selected type product from the list of products
index = self.productType.index(selectedProduct)
#Create the instance of the recyclable product with its name, quanitiy and fees.
item = RecyclableItem(selectedProduct, quantity, self.productValue[index])
#acept the product
self.accept_product(item)
#calculate the product
self.payout(int(quantity)*float(self.productValue[index]))
#Print the message
print("You added "+str(quantity)+" "+str(selectedProduct)+"(s) for $"+str(self.productValue[index])+" each. You have $"+str(self.totalPayout)+".")
#This method will be used to calculate the total payout or the user
def payout(self, amount):
self.totalPayout = self.totalPayout + amount
#This method will be used print the summary of the total item recycled
def print_receipt(self):
print("\n-----------------Final Receipt---------------------\n")
totalItems=0;
for item in self.recycledProductList:
print(str(item.get_quantity())+" "+str(item.get_type())+"s "+str(float(int(item.get_quantity())*float(item.get_fees()))))
totalItems=int(totalItems)+int(item.get_quantity())
print("Number of items "+str(totalItems))
print("Amount paid: $"+str(self.totalPayout));
print("\nThank you for recycling at FedUni!\n")
class RecyclableItem:
#This instance variable used to hold the value of product type
productType="";
#This is instance variable which is used to hold the product quantity
quantity=""
#Variable to hold recycling fee of one unit
fees=0
#This is RecyclableItem of the product class which is being used for the initialization of the product
def __init__(self, productType, quantity, fees):
#this statement used to initialize the productType variable
self.productType=productType
#This is used to initialize the quantity of the item
self.quantity=quantity
#This is used to initialize the recycling fee of the product per unit
self.fees=fees
#This method used to get the item recycling fee
def get_fees(self):
return self.fees
#This item used to get the quantity of the particular instance
def get_quantity(self):
return self.quantity
#This item used to get the type of the product
def get_type(self):
return self.productType;
#Import the RecyclingMachine
from RecyclingMachine import RecyclingMachine
#Create the instance of the RecyclingMachine
recycle = RecyclingMachine()
#Run while loop unti
while(True):
#Get the total balance of the user
balance = recycle.totalPayout;
#Take user choice
choice = input("\nBalance: $"+str(balance)+" Please select a product: (Can, Bottle, Paper, Stop):")
#Check if user opt to stop the recycling
if(choice.upper() == "STOP"):
#If user chosen to Stop the print the receipt of the user
recycle.print_receipt()
#Take user's next choice
nextChoice = input("(N)ext customer, or (Q)uit? ")
#Check if user chosen to quit
if(nextChoice == 'q' or nextChoice =='Q'):
#Exit from the program
exit()
#Check if user chosen new customer
elif(nextChoice == 'n' or nextChoice == 'N'):
#Reinitialize the RecyclingMachine instance
recycle = RecyclingMachine()
#If user chose some other item type
else:
#Take quantity of item type from user
quantity = input("\nHow many "+choice+"s do you have?: ")
#Accept all quantity for Recycling
for i in range(0,int(quantity)):
#Print the acceptance message
print(choice +' accepted')
#call method of select the product
recycle.select_product( choice, quantity)
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) |
|
|