From 187d40b46d1ba338c5b00e2d3d3d82951b9822d3 Mon Sep 17 00:00:00 2001 From: blvckk Date: Thu, 26 Jan 2017 21:49:24 +0000 Subject: [PATCH 1/6] Added header & Implementation file --- Books.cpp | 18 ++++++++++++++++++ Books.h | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Books.cpp create mode 100644 Books.h diff --git a/Books.cpp b/Books.cpp new file mode 100644 index 0000000..5f6db70 --- /dev/null +++ b/Books.cpp @@ -0,0 +1,18 @@ +#Include "Books.h" + +void book::setbName(string x) +{ +bName = x; +} +stringbook:: getbName() +{ +return bName; +} +void book:: setprice (double y) +price =y; +} +double book:: getprice() +{ +return price; +} + diff --git a/Books.h b/Books.h new file mode 100644 index 0000000..e29a5c4 --- /dev/null +++ b/Books.h @@ -0,0 +1,19 @@ +#Include +#Include < string> +using namespace std; + +class books +{ +private: +string bName; +double price; + +public: +books(); +void setbName(string); +string getbName (); +void setprice (double); +double getprice(); +}; + + From b77a5328fd590df84adb37c08d4e0ce17cf0f28a Mon Sep 17 00:00:00 2001 From: blvckk Date: Thu, 26 Jan 2017 22:10:13 +0000 Subject: [PATCH 2/6] Added constructor --- Books.cpp | 8 ++++++-- Books.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Books.cpp b/Books.cpp index 5f6db70..2338963 100644 --- a/Books.cpp +++ b/Books.cpp @@ -1,4 +1,4 @@ -#Include "Books.h" +#include "Books.h" void book::setbName(string x) { @@ -15,4 +15,8 @@ double book:: getprice() { return price; } - +Books::Books () // Contructor - DO NOT RECREATE VARIABLE +{ +bName = ""; +price= 0.0; +}; diff --git a/Books.h b/Books.h index e29a5c4..4c6250a 100644 --- a/Books.h +++ b/Books.h @@ -1,5 +1,5 @@ -#Include -#Include < string> +#include +#include < string> using namespace std; class books From 0668ce73c742ce1cc7929072cce7b9b7433f1896 Mon Sep 17 00:00:00 2001 From: blvckk Date: Thu, 26 Jan 2017 22:25:36 +0000 Subject: [PATCH 3/6] Added Client File --- client.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 client.cpp diff --git a/client.cpp b/client.cpp new file mode 100644 index 0000000..23250a0 --- /dev/null +++ b/client.cpp @@ -0,0 +1,29 @@ +#include +#include +#include "Books.h" +#include +using namespace std; + +int main() +{ +vector Books (4); +string bName; +double price; +for (int=0; i<4; i++) +{ +cout << "Book Title:" << endl; +cin >> bName; +Books [i].setbName (bName); +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; +} From 117c9ca7d08edcfde4fb5c79390a0208f329a284 Mon Sep 17 00:00:00 2001 From: blvckk Date: Thu, 2 Feb 2017 21:09:14 +0000 Subject: [PATCH 4/6] Updated files --- Books.cpp | 11 ++++++----- Books.h | 2 +- client.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Books.cpp b/Books.cpp index 2338963..fa538a8 100644 --- a/Books.cpp +++ b/Books.cpp @@ -1,21 +1,22 @@ #include "Books.h" -void book::setbName(string x) +void books::setbName(string x) { bName = x; } -stringbook:: getbName() +string books:: getbName() { return bName; } -void book:: setprice (double y) +void books:: setprice (double y) +{ price =y; } -double book:: getprice() +double books:: getprice() { return price; } -Books::Books () // Contructor - DO NOT RECREATE VARIABLE +books::books () // Contructor - DO NOT RECREATE VARIABLE { bName = ""; price= 0.0; diff --git a/Books.h b/Books.h index 4c6250a..a049b62 100644 --- a/Books.h +++ b/Books.h @@ -1,5 +1,5 @@ #include -#include < string> +#include using namespace std; class books diff --git a/client.cpp b/client.cpp index 23250a0..8159348 100644 --- a/client.cpp +++ b/client.cpp @@ -6,10 +6,10 @@ using namespace std; int main() { -vector Books (4); +vector Books (4); string bName; double price; -for (int=0; i<4; i++) +for (int i=0; i<4; i++) { cout << "Book Title:" << endl; cin >> bName; From cd9f08d38add27c5f93cbb627ac476eb8be47e02 Mon Sep 17 00:00:00 2001 From: blvckk Date: Thu, 9 Feb 2017 23:15:42 +0000 Subject: [PATCH 5/6] Added Lab #3 --- client.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/client.cpp b/client.cpp index 8159348..3778651 100644 --- a/client.cpp +++ b/client.cpp @@ -4,22 +4,74 @@ #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; + for (int i=0; i<4; i++) { -cout << "Book Title:" << endl; +cout << "Enter the Book Title:" << endl; cin >> bName; -Books [i].setbName (bName); -cout << "Price:" << endl; -cin >> price; -Books[i].setprice (price); + while(bName != "#") //read an unknown number of inputs from keyboard + { + Books.push_back(books); + 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++) + for (int i=0; i<4; i++) { bName= Books[i].getbName(); price= Books[i].getprice(); @@ -27,3 +79,5 @@ cout << bName << " " << price << endl; } cin >> bName; } + + From 762b3cfe5b3c5a4430912b4be27eb634cf9938b6 Mon Sep 17 00:00:00 2001 From: blvckk Date: Mon, 27 Feb 2017 11:55:59 -0400 Subject: [PATCH 6/6] Lab #3 --- client.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client.cpp b/client.cpp index 3778651..08a99a7 100644 --- a/client.cpp +++ b/client.cpp @@ -16,29 +16,38 @@ int linearSearch(auto data, auto key) //prototype 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 { - Books.push_back(books); - cin>>bName; + myObj.setbName(bName); + Books.push_back(myObj); + cin>>bName; } cout<