From 80a3dd95a79c68305ee9ba8a58c164aa6601b7d7 Mon Sep 17 00:00:00 2001 From: catkitcat Date: Thu, 26 Jan 2017 14:52:36 -0400 Subject: [PATCH 1/7] Added header file --- Cat.cpp | 8 ++++++++ Cat.h | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Cat.cpp create mode 100644 Cat.h diff --git a/Cat.cpp b/Cat.cpp new file mode 100644 index 0000000..c8ed2e7 --- /dev/null +++ b/Cat.cpp @@ -0,0 +1,8 @@ +#include +#include +#include "Cat.h" +using namespace std; + +int main() +{ + vectorcats diff --git a/Cat.h b/Cat.h new file mode 100644 index 0000000..956bf2c --- /dev/null +++ b/Cat.h @@ -0,0 +1,24 @@ +#include +using namespace std; +class Cat{ + public: + Cat(){ + name=" "; + age=0.00; + } + void setName (string catN){ + name=catN; + } + void setAge (float catAge){ + age=catAge; + } + string getName(){ + return name; + } + float getAge(){ + return age; + } + private: + string name; + float age; +}; From 5533bd60590150643eb675ef317d13124eb537cc Mon Sep 17 00:00:00 2001 From: catkitcat Date: Thu, 26 Jan 2017 15:13:03 -0400 Subject: [PATCH 2/7] Added cpp file --- Cat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Cat.h b/Cat.h index 956bf2c..52501ef 100644 --- a/Cat.h +++ b/Cat.h @@ -1,3 +1,4 @@ +#include #include using namespace std; class Cat{ From 85ceccc496821ddb29412ef336abc59a03d115cc Mon Sep 17 00:00:00 2001 From: catkitcat Date: Thu, 26 Jan 2017 15:30:01 -0400 Subject: [PATCH 3/7] Added cpp file --- Cat.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Cat.cpp b/Cat.cpp index c8ed2e7..aab04cd 100644 --- a/Cat.cpp +++ b/Cat.cpp @@ -5,4 +5,24 @@ using namespace std; int main() { - vectorcats + Cat cats; + vectorcatVec; + string catName; + int catAge; + + for(int i=0;i<=3;i++) + { + cout<<"Please enter cat name and age \n"; + cin>> catName >> catAge; + cats.setName(catName); + cats.setAge(catAge); + catVec.push_back(cats); + } + + for(int i=0;i<=3;i++) + { + cout< Date: Thu, 26 Jan 2017 15:30:54 -0400 Subject: [PATCH 4/7] added driver file --- driver.cpp | 1 + 1 file changed, 1 insertion(+) create mode 100644 driver.cpp diff --git a/driver.cpp b/driver.cpp new file mode 100644 index 0000000..bc90f7d --- /dev/null +++ b/driver.cpp @@ -0,0 +1 @@ +#include "Cat.h" From ae730473ecb222016c72bad534b98059f7677e7d Mon Sep 17 00:00:00 2001 From: catkitcat Date: Mon, 6 Feb 2017 11:41:26 -0400 Subject: [PATCH 5/7] added to cat.pp --- Cat.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ driver.cpp | 1 + 2 files changed, 65 insertions(+) diff --git a/Cat.cpp b/Cat.cpp index aab04cd..e6d9838 100644 --- a/Cat.cpp +++ b/Cat.cpp @@ -3,6 +3,18 @@ #include "Cat.h" using namespace std; +int linearSearch(auto data, auto key)//prototype +{ + for (int i=0; i < data.size(); i++) + { + if(data[i]==key) + { + return i; + } + } + return -1; +} + int main() { Cat cats; @@ -25,4 +37,56 @@ int main() cout< inputs; + string search_key, input; + int result; + + cout<<"Welcome to \"search it\". We first need some input data."<>input; + + while(input != "#")//read an unknown number of inputs from keyboard + { + inputs.push_back(input); + cin>>input; + } + + cout<>search_key; + + while(search_key != "#")//perform searches until sentinel entered + { + result = linearSearch(inputs,search_key); + + cout<<" '"<>search_key; + } + + cout< Date: Mon, 6 Feb 2017 12:02:27 -0400 Subject: [PATCH 6/7] added files --- Cat.cpp | 99 +++++++++--------------------------------------------- Cat.h | 22 ++++-------- driver.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 100 deletions(-) diff --git a/Cat.cpp b/Cat.cpp index e6d9838..95dabe2 100644 --- a/Cat.cpp +++ b/Cat.cpp @@ -3,90 +3,21 @@ #include "Cat.h" using namespace std; -int linearSearch(auto data, auto key)//prototype -{ - for (int i=0; i < data.size(); i++) - { - if(data[i]==key) - { - return i; +Cat::Cat(){ + name=" "; + age=0.00; + } + void Cat::setName (string catN){ + name=catN; + } + void Cat::setAge (float catAge){ + age=catAge; + } + string Cat::getName(){ + return name; + } + float Cat::getAge(){ + return age; } - } - return -1; -} - -int main() -{ - Cat cats; - vectorcatVec; - string catName; - int catAge; - - for(int i=0;i<=3;i++) - { - cout<<"Please enter cat name and age \n"; - cin>> catName >> catAge; - cats.setName(catName); - cats.setAge(catAge); - catVec.push_back(cats); - } - - for(int i=0;i<=3;i++) - { - cout< inputs; - string search_key, input; - int result; - - cout<<"Welcome to \"search it\". We first need some input data."<>input; - - while(input != "#")//read an unknown number of inputs from keyboard - { - inputs.push_back(input); - cin>>input; - } - - cout<>search_key; - - while(search_key != "#")//perform searches until sentinel entered - { - result = linearSearch(inputs,search_key); - - cout<<" '"<>search_key; - } - - cout< +#include #include "Cat.h" +using namespace std; +int linearSearch(auto data, auto key)//prototype +{ + for (int i=0; i < data.size(); i++) + { + if(data[i]==key) + { + return i; + } + } + return -1; +} + +int main() +{ + Cat cats; + vectorcatVec; + string catName; + int catAge; + + for(int i=0;i<=3;i++) + { + cout<<"Please enter cat name and age \n"; + cin>> catName >> catAge; + cats.setName(catName); + cats.setAge(catAge); + catVec.push_back(cats); + } + + for(int i=0;i<=3;i++) + { + cout< inputs; + string search_key, input; + int result; + + cout<<"Welcome to \"search it\". We first need some input data."<>input; + + while(input != "#")//read an unknown number of inputs from keyboard + { + inputs.push_back(input); + cin>>input; + } + + cout<>search_key; + + while(search_key != "#")//perform searches until sentinel entered + { + result = linearSearch(inputs,search_key); + + cout<<" '"<>search_key; + } + + cout< Date: Sat, 4 Mar 2017 16:51:50 -0400 Subject: [PATCH 7/7] Made changes --- driver.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/driver.cpp b/driver.cpp index 86d1f53..17c0ade 100644 --- a/driver.cpp +++ b/driver.cpp @@ -21,6 +21,8 @@ int main() vectorcatVec; string catName; int catAge; + string search_key; + int result; for(int i=0;i<=3;i++) { @@ -36,10 +38,32 @@ int main() cout<>search_key; + while(search_key != "#")//perform searches until sentinel entered + { + result = linearSearch(catVec,search_key); + + cout<<" '"<>search_key; + } + + cout< inputs; + /*vector inputs; string search_key, input; int result; @@ -87,5 +111,5 @@ int main() cout<