Write the Python class Lunchltem. Instances of this class represent an item that can also be served at lunch, in other words, they are a Menultem with one additional attribute: lunch_price . For example Lunchltem('Tacos', False, 15, 10)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python. 

Consider the follow implementation for the Menultem:
class MenuItem:
def
init_(self, name, isVeggie, price):
self.name
name
%3D
self.isVeggie
isVeggie
self.price
price
%3D
Instances of this class represent an item on a menu and contains three attributes: name (a
non-empty str), isVeggie (boolean), and price (positive integer). For example
Menultem('Beef Stew', False, 15)
Write the Python class Lunchltem. Instances of this class represent an item that can also
be served at lunch, in other words, they are a Menultem with one additional attribute:
lunch_price . For example Lunchltem('Tacos', False, 15, 10)
In addition, write the function reviseMenu(menuList), where menuList is a Python list that
contains Menultems and Lunchltem objects. This function performs an audit of each
Lunchltem on menuList, making sure that each lunch_price is never more than $10.00. A
lunch_price of $12 is changed to $10. An item whose lunch_price is more than 12 is too
expensive to be offered at lunch; therefore, it must be replaced with a new, equivalent
Menultem (that has no lunch price). Items that are not Lunchltem objects are unchanged.
The function modifies menuList; it does not create or return a new menu list.
IMPORTANT: this function is NOT a method of the Lunchltem class. It is a separate
standalone function.
Transcribed Image Text:Consider the follow implementation for the Menultem: class MenuItem: def init_(self, name, isVeggie, price): self.name name %3D self.isVeggie isVeggie self.price price %3D Instances of this class represent an item on a menu and contains three attributes: name (a non-empty str), isVeggie (boolean), and price (positive integer). For example Menultem('Beef Stew', False, 15) Write the Python class Lunchltem. Instances of this class represent an item that can also be served at lunch, in other words, they are a Menultem with one additional attribute: lunch_price . For example Lunchltem('Tacos', False, 15, 10) In addition, write the function reviseMenu(menuList), where menuList is a Python list that contains Menultems and Lunchltem objects. This function performs an audit of each Lunchltem on menuList, making sure that each lunch_price is never more than $10.00. A lunch_price of $12 is changed to $10. An item whose lunch_price is more than 12 is too expensive to be offered at lunch; therefore, it must be replaced with a new, equivalent Menultem (that has no lunch price). Items that are not Lunchltem objects are unchanged. The function modifies menuList; it does not create or return a new menu list. IMPORTANT: this function is NOT a method of the Lunchltem class. It is a separate standalone function.
Example:
Since there is no legible representation for these classes, the list only shows the type of
object and the value of the price attributes
>>> iteml
MenuItem('Beef Stew', False, 15)
%3D
>>> item 2
LunchItem( 'Tacos', False, 12, 9)
%3D
>>> item3 =LunchItem( 'Steak', False, 20, 20)
>>> item4
LunchItem('Fried rice', True, 12, 12)
%3D
>>> myList
[item1, item2, item3, item4]
>>> myList
[MenuItem obj (price:15), LunchItem obj (price:12 lunch_price:9),
LunchItem obj(price:20 lunch_price:20), LunchItem obj (price:12
lunch_price:12)]
>>> reviseMenu(myList)
>>> myList
[MenuItem obj (price:15), LunchItem obj (price:12 lunch_price:9),
MenuItem obj(price:20), LunchItem obj (price:12 lunch_price:10)]
Transcribed Image Text:Example: Since there is no legible representation for these classes, the list only shows the type of object and the value of the price attributes >>> iteml MenuItem('Beef Stew', False, 15) %3D >>> item 2 LunchItem( 'Tacos', False, 12, 9) %3D >>> item3 =LunchItem( 'Steak', False, 20, 20) >>> item4 LunchItem('Fried rice', True, 12, 12) %3D >>> myList [item1, item2, item3, item4] >>> myList [MenuItem obj (price:15), LunchItem obj (price:12 lunch_price:9), LunchItem obj(price:20 lunch_price:20), LunchItem obj (price:12 lunch_price:12)] >>> reviseMenu(myList) >>> myList [MenuItem obj (price:15), LunchItem obj (price:12 lunch_price:9), MenuItem obj(price:20), LunchItem obj (price:12 lunch_price:10)]
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education