how solve problem when remove asset in blold line? #include #include #include #include #include #include using namespace std; struct Assest { string Type; string Title; string Author; string Year_Publication; string UnQID; string ISBN; int num_Items_Record; int num_Items_lib; bool isExistIntoLib; vector DataRows; Assest() { }
how solve problem when remove asset in blold line?
#include <iostream>
#include <string>
#include <iterator>
#include <fstream>
#include <
#include <sstream>
using namespace std;
struct Assest {
string Type;
string Title;
string Author;
string Year_Publication;
string UnQID;
string ISBN;
int num_Items_Record;
int num_Items_lib;
bool isExistIntoLib;
vector<Assest> DataRows;
Assest() {
}
Assest(string tmpType, string tmpTitle, string tmpAuthor, string tmpYear_Publication, string tmpISBN , int tmpNum_Items_lib, int tmpNum_Items_Record, string tmpUnQID ) {
Type = tmpType;
Title = tmpTitle;
Author = tmpAuthor;
Year_Publication = tmpYear_Publication;
UnQID = tmpUnQID;
num_Items_Record = tmpNum_Items_Record;
num_Items_lib = tmpNum_Items_lib;
ISBN = tmpISBN;
isExistIntoLib = false;
}
string toString() {
return Type + ";"+ Title + ";" + Author + ";" + Year_Publication + ";" + ISBN + ";" + to_string(num_Items_lib) + ";" + to_string(num_Items_Record) + ";" + UnQID+";"+ (isExistIntoLib ? "Borrowed" : "BACK");
}
// function Print
void PrintAll() {
cout << "Type : " << Type << endl <<"Title : " << Title << " "<< "Author : " << Author << endl << "Year : " << Year_Publication << endl;
cout << "ID: " << UnQID << endl<< "ISBN : " << ISBN << endl;
cout << "Num Items For Record : " << num_Items_Record << " " << "Num Items For Library : " << num_Items_lib << endl;
cout << "Asset is " << (isExistIntoLib ? "Borrowed" : "BACK") << endl << endl;
}
void setDataRows(vector<Assest> tmpDataRows) {
this->DataRows = tmpDataRows;
}
/// ADD function
void ADD() {
string tmpType, tmpTitle, tmpAuthor, tmpYear_Publication, tmpUnQID;
int tmpNum_Items_Record, tmpNum_Items_lib;
string tmpISBN;
cin.ignore();
cout << "Enter Type : ";
getline(cin, tmpType, '\n');
cout << "Enter Title : ";
getline(cin, tmpTitle, '\n');
cout << "Enter AUTHOR : ";
getline(cin, tmpAuthor, '\n');
cout << "Enter YEAR : ";
getline(cin, tmpYear_Publication, '\n');
cout << "Enter ID : ";
getline(cin, tmpUnQID, '\n');
cout << "Enter ISBN : ";
getline(cin, tmpISBN, '\n');
cout << "Enter Num Items record : ";
cin >> tmpNum_Items_Record;
cout << "Enter Num itms library : ";
cin >> tmpNum_Items_lib;
Assest MyAssest = Assest(tmpType, tmpTitle, tmpAuthor, tmpYear_Publication, tmpISBN , tmpNum_Items_lib, tmpNum_Items_Record,tmpUnQID);
DataRows.push_back(MyAssest);
}
/// remove function
void REMOVE() {
string assetId;
cout << "INPUT ID : " << endl;
cin >> assetId;
for (int i = 0; i < DataRows.size(); i++)// LOOP
{
if (DataRows[i].UnQID == assetId) {
DataRows.erase(DataRows[i]);//remove if get id
cout << "Asset is Removed" << endl;
break;
}
}
}
Step by step
Solved in 2 steps