(Solved Homework): Hi I'm doing a c++ final project that is due on wed, the project involves makeing an inventory so far I created a sign

Hi I’m doing a c++ final project that is due on wed, the project involves makeing an inventory so far I created a sign in and new user functions to be able to save the items the that user buys under his name and password. However, iIneed in inventory.cpp a fucntion to delete an item if the user want to, also a fucntion to find or search an item by the user inputing the item ID or brand (I was thinking to use maps). Im using files to read and write the items names, prices, Id, and brand. The program that I have is not well done, and needs a lot of improvement, I need help to finish this project. Overall, the project is a inventory and im a file to read and write and save all the items information, the project need to have a add, remove, seacrh or find an item based on user inputing its id or brand, also include a total price of the things the user bought, also I need to use maps in some way. PLEASE I NEED HELP! take a look of the program I have so far. Please run the program to have a better view of what the project is about. Please I need help to have a program runing

======================================================== main.cpp

#include “User.h”
#include <iostream>

int signIn(vector<User>&);
void addUser(vector<User>&);
void displayUsers(vector<User>&);

int main() {

vector<User> *allUsers = new vector<User>();
int UserPosition = -1;

bool done = false;
while (done == false) {
cout << “tEnter A Command n 1. Sign inn 2. New Usern 3. Display List Of Users”;
int input = 0;
cin >> input;

//To Sign in
if (input == 1) {
UserPosition = signIn(*allUsers);
User user(&allUsers->at(UserPosition));
//system(“cls”);

}
//To create a new User
if (input == 2) {
addUser(*allUsers);
}
//To see all users
if (input == 3) {
displayUsers(*allUsers);
}
}

}

int signIn(vector<User>& allUsers) {
string testUserName;
string testPassword;
int testUserPosition = -1;
bool isvalid = false;
//validating username
while (isvalid == false) {
cout << “UserName : “;
cin >> testUserName;
for (int x = 0; x < allUsers.size(); x++) {
if (testUserName == allUsers.at(x).getUserName()) {
isvalid = true;
testUserPosition = x;
}
}
if (isvalid == false) {
cout << “UserName Is Not Valid. Try againn”;

}
}
//validating password
isvalid = false;
while (isvalid == false) {
cout << “nPassword : “;
cin >> testPassword;
if (testPassword == allUsers.at(testUserPosition).getPassword()) {
isvalid = true;
return testUserPosition;
}
if (isvalid == false) {
cout << “Password Is Not Validn”;
}
}
return -1;
}

void displayUsers(vector<User>& allUsers) {
cout << “Displaying Usersn”;
for (int x = 0; x < allUsers.size(); x++) {
cout << allUsers.at(x).getUserName() << endl;
cout << allUsers.at(x).getPassword() << “nn”;
}
}

void addUser(vector<User>& users) {
string Testusername;
string Password;
cout << “Enter A New UserName : “;
cin >> Testusername;
cout << “nEnter A New Password : “;
cin >> Password;
User user(Testusername, Password);
users.push_back(user);
}

=================================================================== User.h

#pragma once
#include <iostream>
#include <string>
#include <vector>
#include “Item.h”
#include “Inventory.h”

using namespace std;

class User {
private:
string UserName;
string Password;
vector<Item>Cart;
public:
void shopInventory(User*, vector<Item>);
void showCart(User*);
void checkout(User*);
string getUserName() { return UserName; }
string getPassword() { return Password; }

User();
User(User*);
~User();

User(string userName, string password) {
this->UserName = userName;
this->Password = password;
}
};

======================================================================= User.cpp

#include “User.h”

User::User() {}

User::User(User* user) {
int input = 0;
bool done = false;
while (done == false) {
cout << “Enter -1 To Sign OutnWelcome ” << user->getUserName() << “, What Do You Want To DO? n 1. Shop Inventoryn 2. Show Cartn”;
cin >> input;

//To Show Inventory
if (input == 1) {
Inventory inventory;
shopInventory(user, inventory.inventory);
}

//To Show Cart
if (input == 2) {
showCart(user);
cout << “Would you like Check Out These Items ? y/n n”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
checkout(user);
}
}
//??
if (input == 3) {

}
//To Quit
if (input == -1) {
done = true;
}
}
}

User::~User() {}

void User::shopInventory(User* user, vector<Item> inventory) {
for (int x = 0; x < inventory.size(); x++) {
inventory.at(x).printItem(inventory.at(x));
}
cout << “Would You Like To Add An Item To Your Cart? Y or Nn”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
cout << “Enter The Item To Add 0 to ” << inventory.size();
int add;
cin >> add;
user->Cart.push_back(inventory.at(add));
}
}

void User::showCart(User* user) {
for (int x = 0; x < user->Cart.size(); x++) {
user->Cart.at(x).printItem(Cart.at(x));
}
}

void User::checkout(User* user) {
float grandtotal = 0;
for (int x = 0; user->Cart.size(); x++) {
grandtotal += user->Cart.at(x).getPrice();
}

cout << “You Have ” << Cart.size() << “Items In Your Cartn You Have A Grand Total Of: ”
<< grandtotal << “$nWould You Like To Proceed? Enter Y or N”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
user->Cart.clear();
cout << “Thank You For Your Purchasen”;
}
else
return;
}

========================================================================= Item.h

#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
typedef std::string String;
class Item
{
private:
int inStock = 0;
int itemNumber = 0;
String itemName = “”;
String itemBrand = “”;
float itemPrice = 0;
bool sold;
public:
Item();
~Item();

void printItem(Item &);

void setitemNumber();
void setName();
void setBrand();
void setPrice();
void setStock();

int getitemNumber();
String getName();
String getBrand();
float getPrice();
};

=================================================================== item.cpp

#include “Item.h”

Item::Item() {
std::cout << “Creating New Itemn”;
setName();
setitemNumber();
setBrand();
setPrice();
setStock();
}

Item::~Item() {}

void Item::printItem(Item &item) {
std::cout << “######### ITEM DETAILS ##############” << std::endl;
std::cout << “Item details are : nr”
<< “Item name           : ” << item.getName() << “nr”
<< “Item brand          : ” << item.getBrand() << “nr”
<< “Item serial number : ” << item.getitemNumber() << “nr”
<< “Item price          : ” << item.getPrice() << “nr”
<< std::endl;
std::cout << “######### ITEM DETAILS ##############” << std::endl;
}

void Item::setitemNumber() {
int Number = 0;
std::cout << “Enter the item number” << std::endl;
std::cin >> Number;
this->itemNumber = Number;
}

void Item::setName() {
String Name;
std::cout << “Enter the name of the item” << std::endl;
std::cin >> Name;
this->itemName = Name;
}

void Item::setBrand() {
String Brand;
std::cout << “Enter the brand of the item” << std::endl;
std::cin >> Brand;
this->itemBrand = Brand;
}

void Item::setPrice() {
float Price;
std::cout << “Enter the price of the item” << std::endl;
std::cin >> Price;
this->itemPrice = Price;
}

void Item::setStock() {
int AmountStock;
std::cout << “Enter the quantity in stock” << std::endl;
std::cin >> AmountStock;
this->inStock = AmountStock;
}

int Item::getitemNumber() { return itemNumber; }
String Item::getName() { return itemName; }
String Item::getBrand() { return itemBrand; }
float Item::getPrice() { return itemPrice; }

================================================================= Inventory.h

#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include “Item.h”
#include <fstream>

using namespace std;

class Inventory {
public:
Inventory() {
ifstream infile(“inventory.txt”, ios::in);
char any[255];

while (!infile.eof())
{
infile.getline(any, 50);
cout << any << endl;
}
infile.close();
};

~Inventory() {};
vector<Item> inventory;

void saveItem(Item);
void addItem();
void deleteItem();
void printAll(Inventory);
private:
const int maxInventory = 20;

};

================================================================= Inventory.cpp

void Inventory::saveItem(Item item) {
ofstream file;
file.open(“inventory.txt”, ios::out | ios::app);
if (file.fail()) {
cout << “Failed To Open Filen”;
}
else {
file << item.getName() << endl;
file << item.getBrand() << endl;
file << item.getitemNumber() << endl;
file << item.getPrice() << endl;
}
file.close();
}

void Inventory::addItem() {
Item newItem;
inventory.push_back(newItem);
saveItem(newItem);
}

void Inventory::deleteItem()
{

}

void Inventory::printAll(Inventory inventory) {
for (int x = 0; x < inventory.inventory.size(); x++) {
inventory.inventory.at(x).printItem(inventory.inventory.at(x));
}

}

================================================================= Inventory.txt

chips
12
344353
lays
book
35
255456
drama

Expert Answer

 #include “User.h”

#include <iostream>

int signIn(vector<User>&);
void addUser(vector<User>&);
void displayUsers(vector<User>&);

int main() {

vector<User> *allUsers = new vector<User>();
int UserPosition = -1;

bool done = false;
while (done == false) {
cout << “tEnter A Command n 1. Sign inn 2. New Usern 3. Display List Of Users”;
int input = 0;
cin >> input;

//To Sign in
if (input == 1) {
UserPosition = signIn(*allUsers);
User user(&allUsers->at(UserPosition));
//system(“cls”);

}
//To create a new User
if (input == 2) {
addUser(*allUsers);
}
//To see all users
if (input == 3) {
displayUsers(*allUsers);
}
}

}

int signIn(vector<User>& allUsers) {
string testUserName;
string testPassword;
int testUserPosition = -1;
bool isvalid = false;
//validating username
while (isvalid == false) {
cout << “UserName : “;
cin >> testUserName;
for (int x = 0; x < allUsers.size(); x++) {
if (testUserName == allUsers.at(x).getUserName()) {
isvalid = true;
testUserPosition = x;
}
}
if (isvalid == false) {
cout << “UserName Is Not Valid. Try againn”;

}
}
//validating password
isvalid = false;
while (isvalid == false) {
cout << “nPassword : “;
cin >> testPassword;
if (testPassword == allUsers.at(testUserPosition).getPassword()) {
isvalid = true;
return testUserPosition;
}
if (isvalid == false) {
cout << “Password Is Not Validn”;
}
}
return -1;
}

void displayUsers(vector<User>& allUsers) {
cout << “Displaying Usersn”;
for (int x = 0; x < allUsers.size(); x++) {
cout << allUsers.at(x).getUserName() << endl;
cout << allUsers.at(x).getPassword() << “nn”;
}
}

void addUser(vector<User>& users) {
string Testusername;
string Password;
cout << “Enter A New UserName : “;
cin >> Testusername;
cout << “nEnter A New Password : “;
cin >> Password;
User user(Testusername, Password);
users.push_back(user);
}

=================================================================== User.h

#pragma once
#include <iostream>
#include <string>
#include <vector>
#include “Item.h”
#include “Inventory.h”

using namespace std;

class User {
private:
string UserName;
string Password;
vector<Item>Cart;
public:
void shopInventory(User*, vector<Item>);
void showCart(User*);
void checkout(User*);
string getUserName() { return UserName; }
string getPassword() { return Password; }

User();
User(User*);
~User();

User(string userName, string password) {
this->UserName = userName;
this->Password = password;
}
};

======================================================================= User.cpp

#include “User.h”

User::User() {}

User::User(User* user) {
int input = 0;
bool done = false;
while (done == false) {
cout << “Enter -1 To Sign OutnWelcome ” << user->getUserName() << “, What Do You Want To DO? n 1. Shop Inventoryn 2. Show Cartn”;
cin >> input;

//To Show Inventory
if (input == 1) {
Inventory inventory;
shopInventory(user, inventory.inventory);
}

//To Show Cart
if (input == 2) {
showCart(user);
cout << “Would you like Check Out These Items ? y/n n”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
checkout(user);
}
}
//??
if (input == 3) {

}
//To Quit
if (input == -1) {
done = true;
}
}
}

User::~User() {}

void User::shopInventory(User* user, vector<Item> inventory) {
for (int x = 0; x < inventory.size(); x++) {
inventory.at(x).printItem(inventory.at(x));
}
cout << “Would You Like To Add An Item To Your Cart? Y or Nn”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
cout << “Enter The Item To Add 0 to ” << inventory.size();
int add;
cin >> add;
user->Cart.push_back(inventory.at(add));
}
}

void User::showCart(User* user) {
for (int x = 0; x < user->Cart.size(); x++) {
user->Cart.at(x).printItem(Cart.at(x));
}
}

void User::checkout(User* user) {
float grandtotal = 0;
for (int x = 0; user->Cart.size(); x++) {
grandtotal += user->Cart.at(x).getPrice();
}

cout << “You Have ” << Cart.size() << “Items In Your Cartn You Have A Grand Total Of: ”
<< grandtotal << “$nWould You Like To Proceed? Enter Y or N”;
char choice;
cin >> choice;
if (toupper(choice) == ‘Y’) {
user->Cart.clear();
cout << “Thank You For Your Purchasen”;
}
else
return;
}

========================================================================= Item.h

#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
typedef std::string String;
class Item
{
private:
int inStock = 0;
int itemNumber = 0;
String itemName = “”;
String itemBrand = “”;
float itemPrice = 0;
bool sold;
public:
Item();
~Item();

void printItem(Item &);

void setitemNumber();
void setName();
void setBrand();
void setPrice();
void setStock();

int getitemNumber();
String getName();
String getBrand();
float getPrice();
};

=================================================================== item.cpp

#include “Item.h”

Item::Item() {
std::cout << “Creating New Itemn”;
setName();
setitemNumber();
setBrand();
setPrice();
setStock();
}

Item::~Item() {}

void Item::printItem(Item &item) {
std::cout << “######### ITEM DETAILS ##############” << std::endl;
std::cout << “Item details are : nr”
<< “Item name           : ” << item.getName() << “nr”
<< “Item brand          : ” << item.getBrand() << “nr”
<< “Item serial number : ” << item.getitemNumber() << “nr”
<< “Item price          : ” << item.getPrice() << “nr”
<< std::endl;
std::cout << “######### ITEM DETAILS ##############” << std::endl;
}

void Item::setitemNumber() {
int Number = 0;
std::cout << “Enter the item number” << std::endl;
std::cin >> Number;
this->itemNumber = Number;
}

void Item::setName() {
String Name;
std::cout << “Enter the name of the item” << std::endl;
std::cin >> Name;
this->itemName = Name;
}

void Item::setBrand() {
String Brand;
std::cout << “Enter the brand of the item” << std::endl;
std::cin >> Brand;
this->itemBrand = Brand;
}

void Item::setPrice() {
float Price;
std::cout << “Enter the price of the item” << std::endl;
std::cin >> Price;
this->itemPrice = Price;
}

void Item::setStock() {
int AmountStock;
std::cout << “Enter the quantity in stock” << std::endl;
std::cin >> AmountStock;
this->inStock = AmountStock;
}

int Item::getitemNumber() { return itemNumber; }
String Item::getName() { return itemName; }
String Item::getBrand() { return itemBrand; }
float Item::getPrice() { return itemPrice; }

================================================================= Inventory.h

#pragma once
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include “Item.h”
#include <fstream>

using namespace std;

class Inventory {
public:
Inventory() {
ifstream infile(“inventory.txt”, ios::in);
char any[255];

while (!infile.eof())
{
infile.getline(any, 50);
cout << any << endl;
}
infile.close();
};

~Inventory() {};
vector<Item> inventory;

void saveItem(Item);
void addItem();
void deleteItem();
void printAll(Inventory);
private:
const int maxInventory = 20;

};

================================================================= Inventory.cpp

void Inventory::saveItem(Item item) {
ofstream file;
file.open(“inventory.txt”, ios::out | ios::app);
if (file.fail()) {
cout << “Failed To Open Filen”;
}
else {
file << item.getName() << endl;
file << item.getBrand() << endl;
file << item.getitemNumber() << endl;
file << item.getPrice() << endl;
}
file.close();
}

void Inventory::addItem() {
Item newItem;
inventory.push_back(newItem);
saveItem(newItem);
}

void Inventory::deleteItem()
{

}

void Inventory::printAll(Inventory inventory) {
for (int x = 0; x < inventory.inventory.size(); x++) {
inventory.inventory.at(x).printItem(inventory.inventory.at(x));
}

}

iWriteHomework
Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Professional and Experienced Academic Writers

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents