Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes:
4. Write a class named RetailItem that holds data about an item in a retail store. The class should store the following data in attributes: item description, units in inventory, and price. Once you have written the class, write a program that creates three objects and stores the following data in them: Description Units in Inventory Price 59.95 Item #1 Item #2 Item #3 Jacket Designer Jeans Shirt 12 40 20 34.95 24.95 5. This exercise assumes you have created the Retailltem class for Exercise 4. Create a Cash Register class that can be used with the Retailltem class. The Cash Register class should be able to internally keep a list of Retailltem objects. The class should have the following methods: A method named purchase_item that accepts a Retailltem object as an argument. Each time the purchase_item method is called, the Retailltem object that is passed as an argument should be added to the list. A method named get total that returns the total price of all the Retailltem objects stored in the Cash Register object's internal list. A method show_items named that displays data about the Retailltem objects stored in the Cash Register object's internal list. A method named clear that should clear the CashRegister object's internal list. Demonstrate the class in a program that allows the user to select several items for purchase. When the user is ready to check out, the program should display a list of all the items he or she has selected for purchase, as well as the total price
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started