For your homework assignment, build a simple application for use by a local retail store. Your program should have the following classes: Item: Represents an item a customer might buy at the store. It should have two attributes: a String for the item description and a float for the price. This class should also override the __str__ method in a nicely formatted way. Customer: Represents a customer at the store. It should have three attributes: a String for the customer's name, a Boolean for the customer's preferred status, and a list of 5 indexes to hold Item objects. Include the following methods: make_purchase: accepts a String and a double as parameters to represent the name and price of an item this customer is purchasing. Create a new Item object with this info and append it to the internal list. If the customer is a preferred customer based on the Boolean attribute's value, take 10% off the total sale price. __str__: Override this method to print the customer's name and every purchase they have made (make sure the Item's information prints as well, not just its object type). Once you have built these classes, build a driver program to test them. The driver does not need to be too in-depth, but you should at the very least create two Customers, one preferred and one not, make a few purchases for each (pass whatever data you would like to make_purchase), and then print them with the print method. No need for user input on this assignment.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
For your homework assignment, build a simple application for use by a local retail store. Your
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 1 images