Question: I need help separating this code into 2 classes. User class and item class, the code works correctly, you just have to separate it by
I need help separating this code into classes.
User class and item class, the code works correctly, you just have to separate it by classes.
#include
#include
#include
#include "user.h
#include "article.h
using the standard namespace;
int main
fstream file;
string user, pass;
string fuser, fpass;
vectorcart;
inner band ;
file.openusertxt;
if file.isopen
cout "Error opening file" endl;
return ;
cout "User: ;
cin user;
cout "Password: ;
cin pass;
while file.eof
file fuser fpass;
if fuser user && fpass pass
band ;
break;
file.close;
if band
element objPaper;
element objFeather;
element objLaptop;
element objPencil;
item objDraft;
vector elements obj obj obj obj obj;
internal choice;
do
cout Welcome to my online store election;
change choice
Case :
int subselect;
cout "How would you like to consult the articles?
;
cout Prices below a certain quantity.
;
cout Prices above a certain quantity
;
cout Name
;
cout "Enter your choice: ;
cin subselection;
int pricelimit;
string element name;
changesuboption
Case :
case :
cout "Enter price limit: ;
cin price limit;
break;
case :
cout "Enter the element name: ;
cin element name;
break;
cout "Available elements:
;
for int i ; i items.size; i
bool display false;
if subchoice && itemsigetPrice priceLimit display true;
if subchoice && itemsigetName item name display true;
if show
cout i itemsigetName Price: $ itemsigetPrice endl;
charade;
cout Do you want to add an item to your cart? YN: ;
cin add;
if add Y
int itemNumber, quantity;
cout "Enter item number: ;
cin item number;
cout "How many pieces?";
cin quantity;
itemsitem number setQuantityquantity;
cart.pushbackitemsitemNum ;
cout "Item added to cart.
;
continuous chain;
cout Do you want to exit to the main menu or continue adding items? MenuAdd: ;
cin cont;
while cont "Add"
int itemNumber, quantity;
cout "Enter item number: ;
cin item number;
cout "How many pieces?";
cin quantity;
itemsitem number setQuantityquantity;
cart.pushbackitemsitemNum ;
cout "Item added to cart.
;
cout Do you want to exit to the main menu or continue adding items? MenuAdd: ;
cin cont;
break;
case :
cout "Your cart:
;
total integer ;
for int i ; i cart.size; i
cout i cartigetName Price: $ cartigetPrice Quantity: cart igetQuantity endl;
total cartigetPrice cartigetQuantity;
cout "Total to pay: $ total endl;
string buyOrCont;
cout Do you want to finish or continue shopping? FinishBuy: ;
cin buyOrCont;
if buyOrCont "Finish"
cout "Press Ok to close the sale..
;
string Ok;
cin Ok;
if Okay "Okay"
cout "Sale successfully closed. Thank you for shopping with us
;
cart.clear;
break;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
