Menu

Using Python 3 Writing Rather Primitive Online Store Simulator Three Classes Product Custo Q43812497

USING PYTHON 3: You will be writing a (ratherprimitive) online store simulator. It will have three classes:Product, Customer, and Store. All data members of each class shouldbe marked as private and the classes should have any get or setmethods that will be needed to access them. Here are descriptionsof methods for the three classes:

Product:

A Product object represents a product with an ID code, title,description, price and quantity available.

  • init method – takes as parameters five values with which toinitialize the Product’s id_code, title, description, price, andquantity_available.
  • get methods for each of the data members, named get_id_code,get_title, get_description, get_price, andget_quantity_available
  • decrease_quantity – decreases the quantity available byone

Customer:

A Customer object represents a customer with a name and accountID. Customers must be members of the Store to make a purchase.Premium members get free shipping.

  • init method – takes as parameters three values with which toinitialize the Customer’s name, account_ID, and whether thecustomer is a premium_member.
  • you decide how to represent a Customer’s cart
  • get methods named get_name and get_account_ID
  • is_premium_member – returns whether the customer is a premiummember
  • add_product_to_cart – adds the product ID code to theCustomer’s cart
  • empty_cart – empties the Customer’s cart

Store:

A Store object represents a store, which has some number ofproducts in its inventory and some number of customers asmembers.

  • you decide how to represent a Store’sinventory and members
  • init method – whatever initialization needs to be done for yourStore
  • add_product – adds a product to the inventory
  • add_member – adds a customer to the members
  • get_product_from_ID – returns the Product with the matching ID.If no matching ID is found, it returns the special value None
  • get_member_from_ID – returns the Customer with the matching ID.If no matching ID is found, it returns the special value None
  • product_search – return a sorted list of ID codes for everyproduct whose title or description contains the search string. Thefirst letter of the search string should be case-insensitive, i.e.a search for “wood” should match Products that have “Wood” in theirtitle or description, and a search for “Wood” should match Productsthat have “wood” in their title or description. You may assume thatthe search string will consist of a single word.
  • add_product_to_member_cart – If the product isn’t found in theinventory, return “product ID not found”. If the product was found,but the member isn’t found in the members, return “member ID notfound”. If both are found and the product is still available, callthe member’s addProductToCart method to add the product and thenreturn “product added to cart”. If the product was not stillavailable, return “product out of stock”. This function does notneed to check how many of that product are available – just thatthere is at least one. It should not change how many are available- that happens during checkout. The same product can be addedmultiple times if the customer wants more than one ofsomething.
  • check_out_member – If the member ID isn’t found, raise anInvalidCheckoutError (you’ll need to define thisexception class). Otherwise return the charge for the member’scart. This will be the total cost of all the items in the cart, notincluding any items that are not in the inventory or are out ofstock, plus the shipping cost. If a product is not out of stock,you should add its cost to the total and decrease the availablequantity of that product by 1. Note that it is possible for an itemto go out of stock during checkout. For example, if the customerhas two of the same product in their cart, but the store only hasone of that product left, the customer will be able to buy the onethat’s available, but won’t be able to buy a second one, becauseit’s now out of stock. For premium members, the shipping cost is$0. For normal members, the shipping cost is 7% of the total costof the items in the cart. When the charge for the member’s cart hasbeen tabulated, the member’s cart should be emptied, and the chargeamount returned.

You must include a main function that runs if the file is run asa script, but not if the file is imported. The main function shouldtry to check out a member. If an InvalidCheckoutError is raised, anexplanatory message should be printed for the user (otherwise thecheckout should proceed normally).

In addition to your file containing the code for the aboveclasses, you must also submit a file that contains unit tests foryour Store.py file. It must have at least five unit tests and useat least three different assert functions.

Your files must be named: Store.py andStoreTester.py

Example of the data. I could only figure out how towrite it in C++, so if you could still convert it to Python 3, Iwould greatly appreciate it.

Product.hpp

#ifndef PRODUCT_HPP
#define PRODUCT_HPP

#include <string>

class Product
{
private:
std::string idCode;
std::string title;
std::string description;
double price;
int quantityAvailable;
public:
Product(std::string id, std::string t, std::string d, double p, intqa);
std::string getIdCode();
std::string getTitle();
std::string getDescription();
double getPrice();
int getQuantityAvailable();
void decreaseQuantity();
};

#endif

Customer.hpp

#ifndef CUSTOMER_HPP
#define CUSTOMER_HPP

#include <vector>
#include “Product.hpp”

class Customer
{
private:
std::vector<std::string> cart;
std::string name;
std::string accountID;
bool premiumMember;
public:
Customer(std::string n, std::string a, bool pm);
std::string getAccountID();
std::vector<std::string> getCart();
void addProductToCart(std::string);
bool isPremiumMember();
void emptyCart();
};

#endif

Store.hpp

#ifndef STORE_HPP
#define STORE_HPP

#include <string>
#include “Customer.hpp”

class Store
{
private:
std::vector<Product*> inventory;
std::vector<Customer*> members;
public:
void addProduct(Product* p);
void addMember(Customer* c);
Product* getProductFromID(std::string);
Customer* getMemberFromID(std::string);
void productSearch(std::string str);
void addProductToMemberCart(std::string pID, std::stringmID);
void checkOutMember(std::string mID);
};

#endif

Expert Answer


Answer to USING PYTHON 3: You will be writing a (rather primitive) online store simulator. It will have three classes: Product, Cu…

OR