Question

This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of ...

This is my assignment in Python. Please help me thank you

Design type 1:

# Creating an object of the class "Burger"

theOrder = Burger()

# calling the main method

theOrder.main()

# And the class is like:

class Burger:

# You may need to have a constructor

def __init__(self):
self._orderDict = {}

self._priceBeforeTax = 0

self._priceAfterTax = 0

# you may have the tax rate also as an instance variable. But as I mentioned, you can use your

# own deign.

   ....

# That the class has a main method to run other needed methods. Like:

def main(self):
self.displayMenu()
self.getInput()

self.calculateTheBill()

...

self.printTheBill()

self.saveToFileTheBill()

  

def displayMenu(self):

# display the menu

...

def getInput(self):

# Get the order from the user and fill the "_orderDict" instance variable. - You may return some

# variable from this class. It's depend on your design.

....

  

def calculateTheBill(self):

# Calculate the price before and after tax. - You may pass in or return some variable from this class.

# It's depend on your design.

...

def printTheBill(self):

# Print the bill on the console - You may pass some variable in this class. It's depend

# on your design.

def saveToFileTheBill(self):

# Save the bill in a file - You may pass some variable in this class. It depends

# on your design.

# This method can be merged with the printTheBill together. It depends on your design.

Design type 2:

# Creating an object of the class "DeAnzaBurger"

theOrder = Burger()

# calling the needed method

theOrder.displayMenu()
theOrder.getInput()

theOrderDict = theOrder.getOrderDict()

theOrder.calculateTheBill(theOrderDict )

theOrderBalance = theOrder.getTheBalance()

...

theOrder.printTheBill(theOrderBalance)

theOrder.saveTheBillToFile(theOrderBalance )

# And the class may be the same as the design type 1 class with some changes.

class Burger:

...

...

For design type 2, you may need mutators and accessors:

def setOrderDict(theUpdatedOrderDict):

  _orderDict = theUpdatedOrderDict

def getOrderDict():

return _orderDict

***********************************************************************************************************

  • Use a dictionary as a data structure to send data from a method to another method. Or make it as an instance variable. Then you can fill it and use it everywhere in your class.
    • you may need 2 dictionaries("_" means they are private):

_menuDict = {'De Anza Burger':5.25,'Bacon Cheese':5.75, ... ,'Don Cali Burger':5.95}

which the keys are the food name and the values are the prices.

_orderDict = {'Bacon Cheese':5, ... ,'Don Cali Burger':2}

which the keys are the order (food) name and the values are the quantities of the orders.

(As I mentioned, these all are samples and you can have your own designs and names.)

  • Print the bill on the screen and also in a file.

Use the following naming style for your file - you may use it in the saveToFileTheBill method.

import time # <= This line can be on the top of your code
timeStamp = time.time()
# print(timeStamp) # <= You don't need this line. I just put it here to show you what the output will be.
#1533498418.1082168

import datetime
orderTimeStamp = datetime.datetime.fromtimestamp(timeStamp).strftime('%Y-%m-%d %H-%M-%S')
# print(orderTimeStamp)   # <= You don't need this line. I just put it here to show you what the output will be.
#2018-08-05 12-46-58

# Then concatenate this string with ".txt"

orderTimeStamp = orderTimeStamp + '.txt'

# 2018-08-05 12-46-58.txt

# Now you can use this string as your output file name:

fileHandleToSaveTheBill = open(orderTimeStamp,'w')

  • Use strip() function to strip your inputs.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Impost java cett Impot Java.io.夭. eg Buffered Readesne gfuredReadex (me St necum Read ey pu ._ be.toye- ta)し宀0. C, pTr(e rOLSMein im out.psintn CK.mext ElemetU4 . rext Sps kam.out printloauy Orders do yu oaut to plece): hteYeCder get (sto)) pYice, before-taxspร.ce befe,..:tw. t - oYe al (ピーatlas-tox) ut) thoos to Excep axtIn yourO Exception n2c dexput Cohese S 25) Oxde. Put (Don Cali Burger,595), a Order.main (ovde)

Add a comment
Know the answer?
Add Answer to:
This is my assignment in Python. Please help me thank you Design type 1: # Creating an object of ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • It's my python homework. Not Java. Design type 1: # Creating an object of the class...

    It's my python homework. Not Java. Design type 1: # Creating an object of the class "DeAnzaBurger" theOrder = DeAnzaBurger() # calling the main method theOrder.main() # And the class is like: class DeAnzaBurger: # You may need to have a constructor def __init__(self): self._orderDict = {} self._priceBeforeTax = 0 self._priceAfterTax = 0 # you may have the tax rate also as an instance variable. But as I mentioned, you can use your # own deign.    .... # That...

  • Python3 : question about object-oriented programming, Please write program in the template(critter.py),specific information is on the graphs the missing words in the 4th line are 'To save an attri...

    Python3 : question about object-oriented programming, Please write program in the template(critter.py),specific information is on the graphs the missing words in the 4th line are 'To save an attribute, attach it to this self keyword' W11 - Critters Implement the Critter class. Each critter C has attributes species, size, and age The constructor accepts arguments for the attributes above, in the order above. You can expect size and age to be numeric values Each critter C has a can_eat) method,...

  • Please help me to do my assignment it should be python. Thank you Write a menu-driven...

    Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...

  • 11.2 Problem Set 2: PostScript Stack Commands (in python please) For this assignment you are to...

    11.2 Problem Set 2: PostScript Stack Commands (in python please) For this assignment you are to implement a PostScript command interpreter using a Stack. You must implement the stack using a singly-linked list. Solutions that use a data structure other than a singly-linked list will received no credit. The interpreter must read and execute a string of PostScript commands based on the following definitions: 1. = objn objn-1 … obj1 = : objn-1 … obj1 This command removes the topmost...

  • In Python !!! In this exercise you will continue to work with Classes and will build...

    In Python !!! In this exercise you will continue to work with Classes and will build on the Book class in Lab 13.10; you should copy the code you created there as you will need to extend it in this exercise. You will extend the Book class to accommodate the case where there may be multiple authors for a book. The attribute author should become a list. The constructor will still take a parameter that is a string for author,...

  • Python only please, thanks in advance. Type up the GeometricObject class (code given on the back...

    Python only please, thanks in advance. Type up the GeometricObject class (code given on the back of the paper). Name this file GeometricObjectClass and store it in the folder you made (xxlab14) 1. Design a class named Rectangle as a subclass of the GeometricObject class. Name the file RectangleClass and place it in the folder. 2. The Rectangle class contains Two float data fields named length and width A constructor that creates a rectangle with the specified fields with default...

  • IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand...

    IN PYTHON Assignment Overview This assignment will give you experience on the use of classes. Understand the Application The assignment is to first create a class calledTripleString.TripleStringwill consist of threeinstance attribute strings as its basic data. It will also contain a few instance methods to support that data. Once defined, we will use it to instantiate TripleString objects that can be used in our main program. TripleString will contain three member strings as its main data: string1, string2, and string3....

  • PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please...

    PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList:     def __init__(self):         self.__head = None         self.__tail = None         self.__size = 0     def insert(self, i, data):         if self.isEmpty():             self.__head = listNode(data)             self.__tail = self.__head         elif i <= 0:             self.__head = listNode(data, self.__head)         elif i >= self.__size:             self.__tail.setNext(listNode(data))             self.__tail = self.__tail.getNext()         else:             current = self.__getIthNode(i - 1)             current.setNext(listNode(data,...

  • Please show all work and answer all parts using python, thanks! Instructions You will need to...

    Please show all work and answer all parts using python, thanks! Instructions You will need to create four files: • Shape2D.py - file containing a class definition containing properties all Shapes could possibly have. • Circle.py - file containing a class definition of a Circle that inherits from the Shape2D class. Square.py - file containing a class definition of a Square that inherits from the Shape2D class. • testFile.py - file containing pytest functions testing the Shape2D, Circle, and Square...

  • PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment...

    PYTHON. Continues off another code(other code is below). I don't understand this. Someone please help! Comment the lines please so I can understand. There are short and med files lengths for each the list of names/ids and then search id file. These are the input files: https://codeshare.io/aVQd46 https://codeshare.io/5M3XnR https://codeshare.io/2W684E https://codeshare.io/5RJwZ4 LinkedList ADT to store student records(code is below). Using LinkedList ADT instead of the Python List. You will need to use the Student ADT(code is below) Imports the Student class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT