Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modular Ham Sandwich Maker Machine Program follow these steps. 1- Code Skeleton: The code skeleton is available through the Code below. The code for assignment

Modular Ham Sandwich Maker Machine Program

follow these steps.

1- Code Skeleton: The code skeleton is available through the Code below. The code for assignment 1 can also be implemented in another way, and you can choose your own way of implementation. 2- Import all modules into main.py Three modules (data, sandwich_maker, cashier) should be imported at the top of main.py. import Create two variables based on data dictionaries (resources and recipes). Then you need to create instance from each. Pay attention sandwich_maker class has a constructor variable (resources) which you imported in last step. = . 3- Place functions in corresponding module: The simplest way to accomplish this is to copy and paste the function into the corresponding module according to the instructions at the end of this document. 4- Fine tune main.py Change the variable names if necessary and run the program. To test your program, you can use the same scenario as in assignment 1. Project Structure: SandwichMaker class in sandwich_makerr.py file: This class contains everything about making sandwiches. The check_resources() and make_sandwich() functions should be placed in this class. Cashier class in cashier.py file: This class contains everything about purchasing. The process_coins() and transaction_result() functions should be placed in this class. Data.py: This file keeps the data we need to run program like a database! Later in the course, we will convert it into a Python class that stores and retrieves data. Main.py: It acts as the starting point of execution for the program.

The Code:

class Cashier: def __init__(self): pass

def process_coins(self): """Returns the total calculated from coins inserted. Hint: include input() function here, e.g. input("how many quarters?: ")""" ###

def transaction_result(self, coins, cost): """Return True when the payment is accepted, or False if money is insufficient. Hint: use the output of process_coins() function for cost input""" ##

recipes = { "small": { "ingredients": { "bread": 2, ## slice "ham": 4, ## slice "cheese": 4, ## ounces }, "cost": 1.75, }, "medium": { "ingredients": { "bread": 4, ## slice "ham": 6, ## slice "cheese": 8, ## ounces }, "cost": 3.25, }, "large": { "ingredients": { "bread": 6, ## slice "ham": 8, ## slice "cheese": 12, ## ounces }, "cost": 5.5, } }

resources = { "bread": 12, ## slice "ham": 18, ## slice "cheese": 24, ## ounces }

import data from sandwich_maker import SandwichMaker from cashier import Cashier

# Make an instance of other classes here resources = data.resources recipes = data.recipes sandwich_maker_instance = ##### cashier_instance = ######

def main(): ### write the rest of the codes ###

if __name__=="__main__": main()

class SandwichMaker: def __init__(self, resources): self.machine_resources = resources

def check_resources(self, ingredients): """Returns True when order can be made, False if ingredients are insufficient.""" #####

def make_sandwich(self, sandwich_size, order_ingredients): ########

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

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions

Question

4. How is culture a contested site?

Answered: 1 week ago