Create a class that models a store. You store has some number of products, for example cookies, chips, soda, and coffee (you get to decided how many products you have). Each product has a price and a stock (that is, how many products you have in the shelf). To modify this object create functions that: model someone making a purchase, where a purchase is composed of a list of items and the quantity to buy. The function should return the total amount to pay and should update the stock of the products. (As a sugestion (and added challenge) you can model the purchase as a class).S model a resupply truck that comes to restock your store
I need help creating a class on python of a store. Above is an example of a car class. and the bottom what I got so far for the store class.
Car Class
Create a class that represents a car. This car object has a brand, a model, a year, mileage, available gas, and a gas efficiency constant. To modify this object create functions that:
- checks if the car can travel a given distance
- if the car has 4 gallons and an efficiency of 4 miles per gallon, can it travel 10 miles?
- increases the mileage by an amount
- updates the consumed fuel by a given mileage
- if I have 10 gallons, an efficiency of 5 miles per gallon, and I traveles 3 miles, how many gallons do I have left?
Store Class
Create a class that models a store. You store has some number of products, for example cookies, chips, soda, and coffee (you get to decided how many products you have). Each product has a price and a stock (that is, how many products you have in the shelf). To modify this object create functions that:
- model someone making a purchase, where a purchase is composed of a list of items and the quantity to buy. The function should return the total amount to pay and should update the stock of the products. (As a sugestion (and added challenge) you can model the purchase as a class).S
- model a resupply truck that comes to restock your store
WHAT I GOT SO FAR
1. Because we only get 2:30 hours to solve, I am unable to explain the code but I have added the comments in code.
These comments will help you to understand the code and its logic.
2. As mentioned, code is about Store class.
3. To save time I have only used cookies, chips, soda, and coffee. You can easily add others by using the copy-paste mechanism.
4. Output screenshots explanation:
A: If stocks are already full, according to that message will get printed.
B: Shows updated stock and our total price.
C: Shows message if we try to purchase out of the stock product.
D: Shows message if we try to give a negative value.
E: Shows invoice.
F: Shows that even if you try to purchase again then stocks are not updated because we haven't refilled our stocks.
At the same time, our invoice gets reset to 0.
G: Shows stocks get reset after refilling the stocks.
Step by step
Solved in 3 steps with 7 images