please rewrite down code using for loop without iterator

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

please rewrite down code using for loop without iterator 

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 (vector<Assest>::iterator it = DataRows.begin(); it != DataRows.end();)// LOOP
        {

            if (it->UnQID == assetId) {
                it = DataRows.erase(it);//remove if get id
                cout << "Asset is Removed" << endl;
                break;

            }

            else
                ++it;
        }
    }

    //SEARCH Title
    void searchTITLE() {
        bool isexist = false;
        string  title;
        cout << "INPUT Title : " << endl;
        cin.ignore();
        getline(cin, title);
        
        for (vector<Assest>::iterator it = DataRows.begin(); it != DataRows.end();)//loop
        {

            if (it->Title == title) {
                it->PrintAll();
                isexist = true;
            }
            ++it;


        }
        if (!isexist)cout << "Sorry Your searched asset not found" << endl;
    }

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education