Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE IN PYTHON! THANK YOU! And follow the format in pictures if possible. Program Specifications Write a SelfPayKiosk class to support basic operations such as

PLEASE IN PYTHON! THANK YOU! And follow the format in pictures if possible.

Program Specifications Write a SelfPayKiosk class to support basic operations such as scan item, cancel transaction, checkout, and make payment. main.py is provided with function stubs. Follow each step to gradually complete all instance methods.

Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main program includes basic calls to the instance methods. Add statements in the main program as instance methods are completed to support development mode testing.

Step 1 (1 pts). 1) SelfPayKiosk class has three attributes: number of customers served, total sales, and current amount due. Complete the constructor to initialize all attributes to 0. Note the global variable for sales tax of 7%. 2) Complete the instance methods to return the number of customers served, total sales, and current amount due. Submit for grading to confirm 1 test passes.

Step 2 (2 pt). Complete the scan_item() instance method. Increase the amount due by parameter price. Do not update amount due if parameter price is negative. Submit for grading to confirm 3 tests pass.

Step 3 (1 pt). Complete the check_out() instance method. Multiply amount due by SALES_TAX and add to amount due. Submit for grading to confirm 4 tests pass.

Step 4 (2 pts). Complete the make_payment() instance method. If parameter payment is enough to pay the amount due, increase total sales by amount due, increment number of customers served, and reset amount due to zero in preparation for the next customer. However, if parameter payment is not enough, update total sales by payment and reduce amount due by payment. Do not make any changes if parameter payment is negative. Submit for grading to confirm 6 tests pass.

Step 5 (1 pt). 1) Complete the reset_kiosk() instance method to reset all attributes to zero. 2) Complete the cancel_transaction() instance method to reset amount due to zero. Submit for grading to confirm 7 tests pass.

Step 6 (2 pts). Complete the simulate_sales() instance method to perform multiple transactions with increasing prices. Use a loop to simulate parameter num_sales transactions. Within the loop call scan_item() with parameter initial_price. Call check_out() and make_payment() to make a payment of $1 more than the amount due. Finally, increase the item price by parameter incr_price in preparation for the next transaction. Submit for grading to confirm 8 tests pass.

Step 7 (1 pt). Add a boolean attribute to indicate if the customer has checked out and is ready to make a payment. Only allow payment after customer has checked out. The cancel_transaction() instance method should not reset amount due if the customer has checked out. Update the following instance methods by inserting assignment statements and if statements related to the boolean attribute: constructor, check_out(), make_payment(), and cancel_transaction(). Ex: Set the the boolean attribute to False only after full payment has been made. Submit for grading to confirm all tests pass.

image text in transcribed

image text in transcribed

image text in transcribed

lass SelfPayKiosk: \# Constructor def __init__(self): \# Complete the constructor self.num_customers =0 \# Return total daily sales def get_total_sales(self): \# Update the return statment return -1.0 \# Return current amount due def get_amount_due(self): \# Update the return statment return -1.0 \# Return number of customers served def get_num_customers(self): return -1 \# Scan one item def scan_item(self, price): \# Type your code here and remove the return statement return -1 \# Apply sales tax to current purchases def check_out(self): \# Type your code here and remove the return statement return -1 \# Cancel current purchases def cancel_transaction(self): \# Type your code here and remove the return statement return -1 \# Reset register for the day def reset_kiosk(self): \# Type your code here and remove the return statement return -1 \# Apply payment to amount due def make_payment(self, payment): \# Type your code here and remove the return statement return -1 \# Simulate multiple transactions def simulate_sales(self, num_sales, initial_price, incr_price): \# Type your code here and remove the return statement return -1 f __name_- == '__main__- : kiosk = SelfPayKiosk() \# Test basic operations kiosk.scan_item(20.49) kiosk.check_out() kiosk.make_payment(25.20) print(f"Number of customers: \{kiosk.get_num_customers()\}") print(f"Amount due: \{kiosk.get_amount_due():.2f\}") print(f"Total Sales: \{kiosk.get_total_sales():.2f\}") \# Add statements as instance methods are completed to support development mode testing \# Test simulate_sales() kiosk.reset_kiosk() kiosk.simulate_sales(100, 5, 2.5) print(f"Number of customers: \{kiosk.get_num_customers()\}") print(f"Amount due: \{kiosk.get_amount_due():.2f\}")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

Briefly explain the concept of fund accounting.

Answered: 1 week ago