ITECH1400 Fundamentals of ProgrammingAssignment 1OverviewThis is an individual assignment that requires you to design, develop and test a small text-based programTimelines and ExpectationsPercentage Value of Task: 20% Due: 5 pm Friday Week 7Minimum time expectation: 20 hoursLearning Outcomes AssessedThe following course learning outcomes are assessed by completing this assessment:Knowledge:K1. Identify and use the correct syntax of a common programming language.K2. Recall and use typical programming constructs to design and implement simple software solutions.K4. Explain the importance of programming style concepts (documentation, mnemonic names, indentation).Skills:S1. Utilise pseudocode and/or algorithms as a major program design technique.S2. Write and implement a solution algorithm using basic programming constructs.S4. Describe program functionality based on analysis of given program code.Application of knowledge and skills:A1. Develop self-reliance and judgement in adapting algorithms to diverse contexts.A2. Design and write program solutions to identified problems using accepted design constructs.CRICOS Provider No. 00103D ITECH1400 Assignment 1 Summer 2019-20 Page 1 of 4
Assessment DetailsThe Federation University Australia Robot Wars are about to commence! The competitors are busy training and now it’s time to prepare to sell spectator tickets.Your task is to design, develop and test a small application for purchasing and recording ticket sales to this eventThe assignment is broken up into three main components:1) Design and model two classes: Ticket and Checkout2) Create an activity chart which describes the behavior of the ticket sales system3) Create a computer program that allows a user to interactively purchase a number of tickets, then provides an opportunity to enter some (fake) credit card information to pay for the tickets, and finally, prints out a receipt for the user (to the screen, not on paper). Finally, the program should backup all the transactions into a text fileYour submission should consist of a Word document containing the first two parts of the assignment, and three Python scripts that implement the computer program (ticket.py, checkout.py and main.py).The main.py script runs the main logic of the program and will use instances of Ticket and Checkout classes to simulate purchasing a spectator ticket.Part 1: Design and Model Two ClassesThis stage requires you to prepare documentation that describes the function of the program and how it is to be tested. There is no coding or code testing involved in this stage.Requirements:1) Read all of this assignment sheet first!!!2) Write an algorithm that describes how the program will operate.a. All program requirements must be included, even if you do not end up including all these requirements in your program code.b. The algorithm must be structured logically so that the program would function correctly.3) Create class diagrams for the Ticket and Checkout classesAdd everything to your Word document.Part 2: Activity FlowchartUsing 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 purchase one or more tickets, accept payment, print a receipt for the user and backup the transaction to a text file.Make sure to use the correct symbols in your diagram for starting, processes, decisions/branches, and ending the process.CRICOS Provider No. 00103D ITECH1400 Assignment 1 Summer 2019-20 Page 2 of 4
Remember to do some (fake) checks when the user enters their credit card details e.g. that enough numbers have been entered.Once you have completed your activity flowchart, add it to your Word document.Part 3: Computer ProgramYou are free to design and implement the software however you see fit. Here are some requirements that must be incorporated into your program1. You must display a welcome message when the program starts. At a minimum, this message should contain the name of your program, the name of the program developer and your student ID.2. The welcome message should also have a row of asterisks at the top and the bottom, just long enough to extend over the text. Hint: Use a For loop for this.3. When the user goes to purchase tickets, they should be able to purchase a child, adult, senior or concession ticket(s). Each ticket category should cost a different amount; it’s up to you to choose how much each ticket costs. They should be able to purchase as many tickets (across all categories) as they like4. When the user goes to finalise their order, the total cost should display on screen. Your program should then ask the user to enter their (fake) credit card details, check the credit card details and, if ‘valid’, display a final receipt5. Finally, the program should backup the transaction into a text fileSubmissionYour Word document and program code be zipped into a single file (a .zip file) and loaded into the Assignment Box provided in Moodle by the due date and time. The naming conventions for the zip file are:ITECH1400_Assignment_1__.zipObviously replace and Assignments will be marked on the basis of fulfilment of the requirements and the quality of the work. In addition to the marking criteria, marks may be deducted for failure to comply with the assignment requirements, including (but not limited to):- Incomplete implementation(s)- Incomplete submissions (e.g. missing files- Poor spelling and grammarThe mark distribution for this assignment is explained on the next page–please look at it carefully and compare your submission to the marking guide.CRICOS Provider No. 00103D ITECH1400 Assignment 1 Summer 2019-20 Page 3 of 4
Marking Criteria/RubricTask Stage 1: Design and Model Two ClassesAvailable MarksStudent Mark Development of an algorithm describing how the program should function• All requirements from the assignment sheet are included 2• Logical structure 2Development of class diagrams• All requirements from the assignment sheet are included 1 • Class diagrams are correctly formatted Stage 2: Activity FlowchartStage 3: Computer Program1 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 decision/branches 2 • Welcome message (including looping structure) 1 • Creates four Ticket instances (child, adult, senior, concession) that may be purchased (student to nominate own pricing schedule)1 • Adds Ticket to the Checkout list of tickets being purchased 2• Allows the checkout of multiple tickets 2• Accepts simulated ‘credit card’ details (including instances when the cards will be refused e.g not enough numbers entered) 2 • Prints a final receipt of the tickets purchased, along with the total cost 2 • Stores the transaction into a file TotalFeedback2 20 Assignments will be marked within 2 weeks of submission. Marks will be loaded in fdlGrades, and a completed marking sheet will be available via Moodle.Plagiarism:Plagiarism is the presentation of the expressed thought or work of another person as though it is one's own without properly acknowledging that person. You must not allow other students to copy your work and must take care to safeguard against this happening. More information about the plagiarism policy and procedure for the university can be found at http://federation.edu.au/students/learning-and- study/online-help-with/plagiarism.CRICOS Provider No. 00103D ITECH1400 Assignment 1 Summer 2019-20Page 4 of 4
Next three are the samples given by the teacher for making an assignment
from product import Product
from checkoutregister import CheckoutRegister
def get_float(prompt):
# Create a blank floating point value of 0.0
value = 0.0
# Loop forever
while True:
try:
# Prompt the user for input and attempt to convert it to a float
value = float(input(prompt))
# If the value is a valid float but is negative print a warning
# then jump back to the top of the loop to ask for input
if value
print("We don't accept negative money!")
continue
# If the valid float was greater than or equal to zero break out of the loop
break
# If the input provided could not be converted to float display suitable warning
except ValueError:
print('Please enter a valid floating point value.')
# Return the valid floating point value
return value
# Function to place scanned products into bags
def bag_products(product_list):
# Declare an empty list of bags, empty list of 'non-bagged' items and say that a bag can only carry 5kg of goods
bag_list = []
non_bagged_items = []
MAX_BAG_WEIGHT = 3.0
# Iterate over products in our list
for product in product_list:
# If a product is more than the max weight of a bag then remove it from the list and add it to the non-bagged items list
if product.weight > MAX_BAG_WEIGHT:
product_list.remove(product)
non_bagged_items.append(product)
# Set the current bag contents to an empty list and create a var for the current bag weight with a value of zero
current_bag_contents = []
current_bag_weight = 0.0
# While there are products in our product list
while len(product_list) > 0:
# Get the product at index 0 and remove it from the product list
temp_product = product_list[0]
product_list.remove(temp_product)
# If adding this item to the current bag does not exceed the maximum bag weight
if current_bag_weight + temp_product.weight
# Add this item to the bag and add the weight of the product to the bag's weight
current_bag_contents.append(temp_product)
current_bag_weight += temp_product.weight
# If adding this item to the current bag WOULD exceed max bag weight
else:
# Add the current bag to the list of bags and reset the current bag contents and weight to be those of this product
bag_list.append(current_bag_contents)
current_bag_contents = [temp_product]
current_bag_weight = temp_product.weight
# If that was the last product add the current bag to the bag list
if (len(product_list) == 0):
bag_list.append(current_bag_contents)
# Loop of each bag printing out it's number...
for index, bag in enumerate(bag_list):
output = 'Bag ' + str(index + 1) + ' contains: '
# ... and the name of each item in the bag
for product in bag:
output += product.name + '\t'
print(output, '\n')
# If we have any non-bagged items in the non-bagged items list...
if (len(non_bagged_items) > 0):
output = 'Non-bagged items: '
# ...then print out the name of each of those too.
for item in non_bagged_items:
output += item.name + '\t'
print(output,'\n')
def check_barcode_exists(barcode):
for product in available_products:
if product.barcode == barcode:
return product
# Could not find product? Return a new 'illegal' product
return Product(-1, 'Not found', 0.0, 0.0)
# Params: barcode, name, price, weight
milk = Product(123, 'Milk, 2 Litres', 2.0, 2.0)
bread = Product(456, 'Bread', 3.5, 0.4)
juice = Product(789, 'Orange Juice, 1 Litre', 3.0, 1.0)
rice = Product(111, 'Basmati Rice, 1Kg', 1.75, 1.0)
cheese = Product(222, 'Goats Cheese', 5.35, 0.6)
soup = Product(333, 'Tomato Soup', 2.30, 0.8)
available_products = []
available_products.append(milk)
available_products.append(bread)
available_products.append(juice)
available_products.append(rice)
available_products.append(cheese)
available_products.append(soup)
while True:
register = CheckoutRegister()
print('\n----- Welcome to FedUni checkout! -----\n')
while True:
barcode = int( input('Please enter the barcode of your item: ') )
product = check_barcode_exists(barcode)
if product.barcode == -1:
print('This product does not exist in our inventory.')
else:
register.scan_product(product)
scan_again = input('Would you like to scan another product? (Y/N) ').capitalize()
if (scan_again == 'N'):
break
while register.payment_due > 0.0:
msg = 'Payment due: ${}. Please enter an amount to pay: '.format(register.payment_due)
register.accept_payment(get_float(msg))
register.print_recipt()
bag_products(register.purchased_items)
again = input('(N)ext customer, or (Q)uit?').capitalize()
if again == 'Q':
break
2)from product import Product
class CheckoutRegister():
def __init__(self):
self.payment_received = 0.0
self.payment_due = 0.0
self.purchased_items = []
def accept_payment(self, amount):
self.payment_received += amount
self.payment_due -= amount
def scan_product(self, product):
self.purchased_items.append(product)
self.payment_due += product.price
print('{} - ${}'.format(product.name, product.price))
def print_recipt(self):
print('\n----- Final Receipt -----\n')
total_cost = float(0.0)
for product in self.purchased_items:
print('{} \t${}'.format(product.name, product.price))
total_cost += product.price
change_amount = self.payment_received - total_cost
print('\nTotal amount due: ${}'.format(total_cost))
print('Amount received: ${}'.format(self.payment_received))
print('Change given: ${}'.format(change_amount))
print()
print('Thank you for shopping at FedUni!\n')
3)
class Product():
def __init__(self, barcode, name, price, weight):
self.barcode = barcode
self.name = name
self.price = price
self.weight = weight