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)

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 11E: a. Write a FractionDemo program that instantiates several Fraction objects and demonstrates that...
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT