From 1f182f38ecf59393dd87bf0e973986d74e5e8569 Mon Sep 17 00:00:00 2001 From: Amon9663 Date: Wed, 8 Feb 2017 12:07:11 -0400 Subject: [PATCH 1/4] Book.h --- Book.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Book.h diff --git a/Book.h b/Book.h new file mode 100644 index 0000000..c15c727 --- /dev/null +++ b/Book.h @@ -0,0 +1,36 @@ +#include +using namespace std; + +#include + + +class Book +{ + private: +int amount; +string bookname; + +public() +{bookname=" "; + amount=0;} + + void setBookname (string n) + {bookname= n;} + string getBookname() + {return bookname;} + + void setAmount (int a) + {amount =a;} + int getAmount() + {return amount;} + + void displayInfo() + {cout<<"Title:"< Date: Tue, 14 Feb 2017 16:39:49 -0400 Subject: [PATCH 2/4] Book.h --- Book.cpp | 23 +++++++++++++++++++++++ Book.h | 37 +++++++++---------------------------- main.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 Book.cpp create mode 100644 main.cpp diff --git a/Book.cpp b/Book.cpp new file mode 100644 index 0000000..0179a43 --- /dev/null +++ b/Book.cpp @@ -0,0 +1,23 @@ +#include +#include +#include "Book.h" + +using namespace std; + +string Book::getBookname() +{return bookname; +} + +int Book::getAmount() + {return amount;} + +void Book::setBookname (string n) + {bookname= n;} + +void Book::displayInfo() + {cout<<"Title:"< -using namespace std; - -#include - +#ifndef BOOK_H +#define BOOK_H class Book { - private: -int amount; -string bookname; + public: + void setBookname(); + void setAmount(); -public() -{bookname=" "; - amount=0;} - - void setBookname (string n) - {bookname= n;} - string getBookname() - {return bookname;} - void setAmount (int a) - {amount =a;} - int getAmount() - {return amount;} - - void displayInfo() - {cout<<"Title:"< +#include +#include +#include "Book.h" +using namespace std; + +int main() +{ + string title; + int amt; + vectorstock; + for (int x=0;x<4; x++){ + cout<< "Enter book title and amount of books"; + cin>> title>>amt; + stock.push_back.setBookname(title); + stock.push_back.setAmount(amt); + } + for (int y=0;y < 4;y++){ + stock.push_back.displayInfo} + + + + + } + From 3e6ef74b41e42198e2491123d8e8fa471394f286 Mon Sep 17 00:00:00 2001 From: Amon9663 Date: Wed, 15 Feb 2017 11:06:51 -0400 Subject: [PATCH 3/4] hellogit-1 --- Book.h | 10 ++++++---- main.cpp | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Book.h b/Book.h index b61658f..38bbd0c 100644 --- a/Book.h +++ b/Book.h @@ -1,12 +1,14 @@ #ifndef BOOK_H #define BOOK_H - +#include class Book { public: - void setBookname(); - void setAmount(); - + void setBookname(std::string n); + void setAmount(int a); + std::string getBookname(); + int getAmount(); + void displayInfo(); private: int amount; diff --git a/main.cpp b/main.cpp index b58de1f..16730f1 100644 --- a/main.cpp +++ b/main.cpp @@ -8,17 +8,20 @@ int main() { string title; int amt; + Book i; vectorstock; for (int x=0;x<4; x++){ - cout<< "Enter book title and amount of books"; + cout<< "Enter book title and amount of books "; cin>> title>>amt; - stock.push_back.setBookname(title); - stock.push_back.setAmount(amt); + + i.setBookname(title); + i.setAmount(amt); + stock.push_back(i); } for (int y=0;y < 4;y++){ - stock.push_back.displayInfo} - + stock[y].displayInfo();} + return 0; } From 16aa69b2707ea8484c9fb760dd317509fde8a34f Mon Sep 17 00:00:00 2001 From: Amon9663 Date: Thu, 23 Feb 2017 19:34:41 -0400 Subject: [PATCH 4/4] main.cpp --- main.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 16730f1..74ea34c 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,8 @@ #include "Book.h" using namespace std; +int linearSearch(auto data, auto key); + int main() { string title; @@ -24,5 +26,37 @@ int main() return 0; - } + + + string search_key, input; + int result; + cout<<"Enter a value to search for: "; + cin>>search_key; + while(search_key != "#") + { + result = linearSearch(stock,search_key); + + cout<<" '"<>search_key; + } + return 0; + +} +int linearSearch(auto data, auto key) +{ + for (int i=0;i < data.size();i++) +{ + if (data[i].getBookname == key){ + return i;} + return -1; +} +}