Question: please write this in python. 1 . Dessert Shop Part 7 : Payment Method Read all instructions carefully. Not following instructions will result in you
please write this in python. Dessert Shop Part : Payment Method
Read all instructions carefully. Not following instructions will result in you not earning the credit you want for the assignment.
Objectives
Create an interface
Implement an interface
Define a type with a specific set of enumerated values
Problem
In Part suppose you want to add functionality to your Dessert Shop application to identify what type of payment the customer will use. A line indicating the payment type will be added to the bottom of the receipt.
To do this, you will add an interface to your Dessert Shop application and update your receipt output as described below.
Possible ways to pay are CASH, CARD, PHONE.
Payable interface
Create a Protocol class Payable.
Define a type PayType whose only legal values areCASH CARD, PHONE
Payable will include two methods:
getpaytype: PayType
setpaytypepaymentmethod: PayType
Raise a ValueError if getpaytype returns anything other than one of these values. Similarly, raise an error if setpaytype attempts to set a value that is not of of these values.
Changes to Order class
Implement the Payment interface. You decide how this is to be implemented and tested.
The default value for pay method in the constructor should be CASH.
Modify str method to include payment type in the order as shown in the example run.
Changes DessertShop class
Add a method that
prompts the user for payment type as shown in the example run
validates the input
returns the payment type to the calling code to set the payment type before an order is printed.
Test Cases
Add pytest test cases to test the payment type of an Order. Create a new test file testorder.py to hold these test cases. You only need test cases: to check for each valid payment type, one to check for trying to set an invalid value and one for trying to get return an invalid value.
We are not testing the user interface with automated test cases, just Order objects with new payment types.
Key Program Requirements
You have added a new Payable interface to your system.
The PDF receipt output has been modified to include the payment method as shown.
Your workspace includes all source files so far and two new files:
testorder.py with cases for testing payment method
Payable interface is defined in file payable.py
Example Run
: Candy
: Cookie
: Ice Cream
: Sunday
What would you like to add to the order? Enter for done:
Enter the type of cookie: Oatmeal Raisin
Enter the quantity purchased:
Enter the price per dozen:
: Candy
: Cookie
: Ice Cream
: Sunday
What would you like to add to the order? Enter for done:
: Cash
: Card
: Phone
Enter payment method:
Receipt
Oatmeal Raisin Cookies Box
cookies @ $dozen: $Tax: $
Candy Corn Bag
lbs @ $lb: $Tax: $
Gummy Bears Bag
lbs @ $lb: $Tax: $
Chocolate Chip Cookies Box
cookies @ $dozen: $Tax: $
Pistachio Ice Cream Bowl
scoops @ $scoop: $Tax: $
Vanilla Sundae Boat
scoops of Vanilla ice cream @ $scoop
Hot Fudge topping @ $: $Tax: $
Oatmeal Raisin Cookies Box
cookies @ $dozen: $Tax: $
Total number of items in order:
Order Subtotals: $Tax: $
Order Total: $
Paid with CARD
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
