diff --git a/Books.cpp b/Books.cpp new file mode 100644 index 0000000..fa538a8 --- /dev/null +++ b/Books.cpp @@ -0,0 +1,23 @@ +#include "Books.h" + +void books::setbName(string x) +{ +bName = x; +} +string books:: getbName() +{ +return bName; +} +void books:: setprice (double y) +{ +price =y; +} +double books:: getprice() +{ +return price; +} +books::books () // Contructor - DO NOT RECREATE VARIABLE +{ +bName = ""; +price= 0.0; +}; diff --git a/Books.h b/Books.h new file mode 100644 index 0000000..a049b62 --- /dev/null +++ b/Books.h @@ -0,0 +1,19 @@ +#include +#include +using namespace std; + +class books +{ +private: +string bName; +double price; + +public: +books(); +void setbName(string); +string getbName (); +void setprice (double); +double getprice(); +}; + + diff --git a/client.cpp b/client.cpp new file mode 100644 index 0000000..08a99a7 --- /dev/null +++ b/client.cpp @@ -0,0 +1,92 @@ +#include +#include +#include "Books.h" +#include +using namespace std; + +int linearSearch(auto data, auto key) //prototype +{ + for (int i=0; i < data.size(); i++) + { + if (data[i].getbName() == key) + { + return i; + } + } // end for + return -1; +} + + +int main() +{ + + + +vector Books (4); +string search_key; +string bName; +double price; +int result; + +books myObj; + + + +for (int i=0; i<4; i++) +{ +cout << "Enter the Book Title:" << endl; +cin >> bName; +//cout << "Enter the Price of the Book:" << endl; +//cin >> price; + + while(bName != "#") //read an unknown number of inputs from keyboard + { + myObj.setbName(bName); + Books.push_back(myObj); + cin>>bName; + } + cout<>search_key; + +//COMPARE SEARCH KEY W/ VECTORS +while (search_key != "#") // # of searches +{ + result = linearSearch (Books,search_key); //vector books -> input bName + + cout<<" '"<>search_key; + + // cout << "Price:" << endl; +//cin >> price; +//Books[i].setprice (price); +} + } +cout << "Book Information: " << endl; + for (int i=0; i<4; i++) +{ +bName= Books[i].getbName(); +price= Books[i].getprice(); +cout << bName << " " << price << endl; +} +cin >> bName; +} + +