C ++ question.Needs to be three seperate files Product.cpp,Customer.cpp, and Sto
ID: 3862545 • Letter: C
Question
C ++ question.Needs to be three seperate files Product.cpp,Customer.cpp, and Store.cpp. You will be writing a (rather primitive) online store simulator. It will have three classes: Product, Customer and Store. To make things a little simpler for you, I am supplying you with the three .hpp files. You will write the three implementation files. You should not alter the provided .hpp files. . . Here are the .hpp files: Product.hpp, Customer.hpp and Store.hpp three files are below the questions; Here are descriptions of methods for the three classes: . Product: A Product object represents a product with an ID code, title, description, price and quantity available. constructor - takes as parameters five values with which to initialize the Product's idCode, title, description, price, and quantity available get methods - return the value of the corresponding data member decreaseQuantity - decreases the quantity available by one . . Customer: A Customer object represents a customer with a name and account ID. Customers must be members of the Store to make a purchase. Premium members get free shipping. constructor - takes as parameters three values with which to initialize the Customer's name, account ID, and whether the customer is a premium member get methods - return the value of the corresponding data member isPremiumMember - returns whether the customer is a premium member addProductToCart - adds the product ID code to the Customer's cart emptyCart - empties the Customer's cart . . Store: A Store object represents a store, which has some number of products in its inventory and some number of customers as members. addProduct - adds a product to the inventory addMember - adds a customer to the members getProductFromID - returns product with matching ID. Returns NULL if no matching ID is found. getMemberFromID - returns customer with matching ID. Returns NULL if no matching ID is found. productSearch - for every product whose title or description contains the search string, prints out that product's title, ID code, price and description addProductToMemberCart - If the product isn't found in the inventory, print "Product #[idCode goes here] not found." If the member isn't found in the members, print "Member #[accountID goes here] not found." If both are found and the product is still available, calls the member's addProductToCart method. Otherwise it prints "Sorry, product #[idCode goes here] is currently out of stock." The same product can be added multiple times if the customer wants more than one of something. checkOut - If the member isn't found in the members, print 'Member #[accountID goes here] not found.' Otherwise prints out the title and price for each product in the cart and decreases the available quantity of that product by 1. If any product has already sold out, then on that line it should print 'Sorry, product #[idCode goes here], "[product name goes here]", is no longer available.' At the bottom it should print out the subtotal for the cart, the shipping cost ($0 for premium members, 7% of the cart cost for normal members), and the final total cost for the cart (subtotal plus shipping). If the cart is empty, it should just print "There are no items in the cart." When the calculations are complete, the member's cart should be emptied. . . Here is an example of how the output of the Store::productSearch method might look (searching for "red"): red blender ID code: 123 price: $350 sturdy blender perfect for making smoothies and sauces hot air balloon ID code: 345 price: $700 fly into the sky in your own balloon - comes in red, blue or chartreuse Here is an example of how the output of the Store::checkOutMember method might look: giant robot - $7000 Sorry, product #345, "live goat", is no longer available. oak and glass coffee table - $250 Subtotal: $7250 Shipping Cost: $0 Total: $7250 . . You must submit on TEACH: Product.cpp, Customer.cpp, and Store.cpp. You do not need to submit the .hpp files. In the main method you use for testing, you should only need to #include Store.hpp. Remember that your compile command needs to list all of the .cpp files. . . customer.hpp #ifndef CUSTOMER_HPP #define CUSTOMER_HPP #include #include "Product.hpp" class Customer { private: std::vector cart; std::string name; std::string accountID; bool premiumMember; public: Customer(std::string n, std::string a, bool pm); std::string getAccountID(); std::vector getCart(); void addProductToCart(std::string); bool isPremiumMember(); void emptyCart(); }; #endif product.hpp #ifndef PRODUCT_HPP #define PRODUCT_HPP #include 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, int qa); std::string getIdCode(); std::string getTitle(); std::string getDescription(); double getPrice(); int getQuantityAvailable(); void decreaseQuantity(); }; #endif store.hpp #ifndef STORE_HPP #define STORE_HPP #include #include "Customer.hpp" class Store { private: std::vector inventory; std::vector 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::string mID); void checkOutMember(std::string mID); }; #endif
Explanation / Answer
Customer.cpp
#include<iostream.h>
Class Product {
private:
std::vector cart;
std::string name;
std::string accountID;
bool premiumMember;
public:
Customer(std::string n, std::string a, bool pm)
{ Cout<<” customer name “;
Cin>>std::n>>endl;
Cout<<” customer id “;
Cin>>std::a>>endl;
Cout<<” premium member “;
Cin>>std::pm>>endl;
}
std::string getAccountID(){ accountID =id;}
std::vector getCart();
void addProductToCart(std::string);
bool isPremiumMember(){ premiumMember= pm;}
void emptyCart(){ cart= 0:}
};
Product.cpp
#include<iostream.h>
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, int qa)
{ cout<<”product id “; cin>> std::id>>endl;
Cout<<”title “;cin>>std::t>>endl;
cout<<”description “; cin>> std::d>>endl;
Cout<<”price “;cin>>std::p>>endl;
cout<<”quantity “; cin>> std::qa>>endl;
}
std::string getIdCode(){ idcode = id; }
std::string getTitle(){ title= t;}
std::string getDescription(){ description= d;}
double getPrice(){ price= p;}
int getQuantityAvailable(){ quantity=qa;}
};
store.cpp
class Store {
private: std::vector inventory;
std::vector members;
public:
void addProduct(Product* p){
for (int i= 0; i<=’’; i++)
{
cout<< “enter product id ”;
cin>> p>>endl;
}
void addMember(Customer* c){
for (int j= 0; j<=’’;ji++)
{
cout<< “enter customer id ”;
cin>> c>>endl;
}
Product* getProductFromID(std::string){
For( int k=0; k<=’’; k++)
{ if ( id = = p[i] ) cout<< “ product is found “<<endl;
}}
Customer* getMemberFromID(std::string){
For(int m=0; m<=’’; m++)}
If( m== c[]) cout <<” customer id”; cin>> a}}
void productSearch(std::string str);
void addProductToMemberCart(std::string pID, std::string mID);
void checkOutMember(std::string mID); };
Main()
#include <iostream.h>
#ifndef CUSTOMER_HPP
#define CUSTOMER_HPP
#include #include "Product.hpp"
class Customer {
private: std::vector cart;
std::string name;
std::string accountID;
bool premiumMember;
public:
Customer(std::string n, std::string a, bool pm);
std::string getAccountID();
std::vector getCart();
void addProductToCart(std::string);
bool isPremiumMember();
void emptyCart(); };
#endif
#ifndef PRODUCT_HPP
#define PRODUCT_HPP
#include 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, int qa);
std::string getIdCode();
std::string getTitle();
std::string getDescription();
double getPrice();
int getQuantityAvailable();
void decreaseQuantity(); };
#endif
#ifndef STORE_HPP
#define STORE_HPP
#include #include "Customer.hpp"
class Store {
private: std::vector inventory;
std::vector 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::string mID);
void checkOutMember(std::string mID); };
#endif
Void main()
{
Product pp; Customer cu; store st;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.