From 8aee8c018101d745e1675a255e1f61c2863c7875 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 10:49:32 -0400 Subject: [PATCH 01/17] Header.h --- Untitled Document | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Untitled Document diff --git a/Untitled Document b/Untitled Document new file mode 100644 index 0000000..0668f40 --- /dev/null +++ b/Untitled Document @@ -0,0 +1,18 @@ +#include +#include +#include +using namespace std; + +class student{ +private: +int ID; +string name; + +string getName(string name){ +return name; +} + +void setID(int x){ +ID=x;} + +}; From df661be39649ebe2a667468873893cf43a2dea92 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 10:59:45 -0400 Subject: [PATCH 02/17] Source.cpp --- Untitled Document => Header.h | 0 Source.cpp | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) rename Untitled Document => Header.h (100%) create mode 100644 Source.cpp diff --git a/Untitled Document b/Header.h similarity index 100% rename from Untitled Document rename to Header.h diff --git a/Source.cpp b/Source.cpp new file mode 100644 index 0000000..65e18a8 --- /dev/null +++ b/Source.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include "Header.h" +using namespace std; + +int main(){ +int number; + +student myStudent; +vector myVector; +cout <<"Enter number"; +cin>>number; +/* +myVector.push_back(number); +*/ +} + From feb12a322ffef353c4c7726ab3777c4dbba5091c Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 13:28:29 -0400 Subject: [PATCH 03/17] Corrected the .h/definition file. --- Header.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Header.h b/Header.h index 0668f40..3eb82de 100644 --- a/Header.h +++ b/Header.h @@ -3,16 +3,17 @@ #include using namespace std; -class student{ +class phone{ private: -int ID; -string name; - -string getName(string name){ -return name; -} - -void setID(int x){ -ID=x;} +string type; +double cost; + +public: +Phone (string = "", double float = 0.0); + void setPhoneType(string n); + string getPhoneType(); + void setPhoneCost(double c); + double getPhoneCost(); + void outputMessage(); }; From 3d9a55d98b16edd7440525279c747ef70447feb4 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 13:36:21 -0400 Subject: [PATCH 04/17] Update Source.cpp --- Source.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Source.cpp b/Source.cpp index 65e18a8..2bf836b 100644 --- a/Source.cpp +++ b/Source.cpp @@ -5,14 +5,7 @@ using namespace std; int main(){ -int number; - -student myStudent; -vector myVector; -cout <<"Enter number"; -cin>>number; -/* -myVector.push_back(number); -*/ -} + string type; + double cost; + phone Apple; From 74670b599f960d4f96d46fbf2e2e26b1eb9cb30e Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 15:40:22 -0400 Subject: [PATCH 05/17] Update Source.cpp --- Source.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source.cpp b/Source.cpp index 2bf836b..9c62119 100644 --- a/Source.cpp +++ b/Source.cpp @@ -8,4 +8,11 @@ int main(){ string type; double cost; phone Apple; + phone Samsung; + phone Huawei; + phone Htc; + + vector myPhone; + phone.setPhoneType(iPhone); + From a0f0731f1e411e68f4384a28c97e81796ecaf15c Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 15:55:01 -0400 Subject: [PATCH 06/17] Update Header.h --- Header.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Header.h b/Header.h index 3eb82de..552f192 100644 --- a/Header.h +++ b/Header.h @@ -10,7 +10,7 @@ double cost; public: -Phone (string = "", double float = 0.0); +Phone (string = "", double = 0.0); void setPhoneType(string n); string getPhoneType(); void setPhoneCost(double c); From d3ab32dc842ab46544067eea6f13a1edb076c6f3 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 16:46:40 -0400 Subject: [PATCH 07/17] Phone.cpp --- Phone.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Phone.cpp diff --git a/Phone.cpp b/Phone.cpp new file mode 100644 index 0000000..9e5b5ee --- /dev/null +++ b/Phone.cpp @@ -0,0 +1,30 @@ +#include +#include +#inlcude "Header.h" +using namespace std; + +phone::Phone (string n , double c){ +phoneType= n; +phoneCost= c; +} + +void phone::setPhoneType(string n){ + phoneType=n; + } + + string phone::getPhoneType(){ + return phoneType; + } + + void phone::setPhoneCost(double c){ + phoneCost= c; + } + + double phone::getPhoneCost(){ + return phoneCost; + } + + void phone::outputMessage(){ + cout << "Your choice of phone: " << phoneType << endl; + cout<< "The accompanied cost is: " << phoneCost << endl; + } From fab8f459376cf4a3f52d203fc892213799f02c6b Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 17:02:18 -0400 Subject: [PATCH 08/17] Rename Phone.cpp to Phone.cpp(aka implementation file) --- Phone.cpp => Phone.cpp(aka implementation file) | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Phone.cpp => Phone.cpp(aka implementation file) (100%) diff --git a/Phone.cpp b/Phone.cpp(aka implementation file) similarity index 100% rename from Phone.cpp rename to Phone.cpp(aka implementation file) From 2e8eaf785ad00198e63b52bae671aef9dad9d67f Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 17:02:52 -0400 Subject: [PATCH 09/17] Rename Header.h to Header.h(aka definition file) --- Header.h => Header.h(aka definition file) | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Header.h => Header.h(aka definition file) (100%) diff --git a/Header.h b/Header.h(aka definition file) similarity index 100% rename from Header.h rename to Header.h(aka definition file) From a3bc0d38b2b126db452a5cf9ef06755cd156b334 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 25 Jan 2017 17:03:24 -0400 Subject: [PATCH 10/17] Rename Source.cpp to Source.cpp(aka client file) --- Source.cpp => Source.cpp(aka client file) | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Source.cpp => Source.cpp(aka client file) (100%) diff --git a/Source.cpp b/Source.cpp(aka client file) similarity index 100% rename from Source.cpp rename to Source.cpp(aka client file) From d7280947ffbfc9903e035bdaca6ed015151aadb5 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Thu, 26 Jan 2017 10:28:06 -0400 Subject: [PATCH 11/17] Update Source.cpp(aka client file) --- Source.cpp(aka client file) | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source.cpp(aka client file) b/Source.cpp(aka client file) index 9c62119..befa0d9 100644 --- a/Source.cpp(aka client file) +++ b/Source.cpp(aka client file) @@ -11,8 +11,12 @@ int main(){ phone Samsung; phone Huawei; phone Htc; + phone myPhone; + + vector myPhone(iPhone, Htc, Samsung , Huawei); +cout<<"My vector contains:"< myPhone; - phone.setPhoneType(iPhone); From a447bfd529c7e30e4d38bdddc0c0021123287718 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 8 Feb 2017 11:22:33 -0400 Subject: [PATCH 12/17] Added the linear search code to the source.cpp file --- Source.cpp(aka client file) | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Source.cpp(aka client file) b/Source.cpp(aka client file) index befa0d9..8509388 100644 --- a/Source.cpp(aka client file) +++ b/Source.cpp(aka client file) @@ -7,15 +7,31 @@ using namespace std; int main(){ string type; double cost; +/* phone Apple; phone Samsung; phone Huawei; phone Htc; phone myPhone; +*/ - vector myPhone(iPhone, Htc, Samsung , Huawei); + vector myPhone/*(iPhone, Htc, Samsung , Huawei)*/; + cout<<"Enter a brad of phone" ; + cin>>type; + myPhone.push_back(type); +/* cout<<"My vector contains:"< Date: Wed, 8 Feb 2017 11:29:07 -0400 Subject: [PATCH 13/17] changed the file names --- Phone.cpp(aka implementation file) => Phone.cpp | 0 Header.h(aka definition file) => Phone.h | 0 Source.cpp(aka client file) => Source.cpp | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Phone.cpp(aka implementation file) => Phone.cpp (100%) rename Header.h(aka definition file) => Phone.h (100%) rename Source.cpp(aka client file) => Source.cpp (100%) diff --git a/Phone.cpp(aka implementation file) b/Phone.cpp similarity index 100% rename from Phone.cpp(aka implementation file) rename to Phone.cpp diff --git a/Header.h(aka definition file) b/Phone.h similarity index 100% rename from Header.h(aka definition file) rename to Phone.h diff --git a/Source.cpp(aka client file) b/Source.cpp similarity index 100% rename from Source.cpp(aka client file) rename to Source.cpp From dc1ba863ab05784c1b13e01e07aea23621fa9953 Mon Sep 17 00:00:00 2001 From: DoubleLift3 Date: Wed, 8 Feb 2017 12:17:17 -0400 Subject: [PATCH 14/17] Added linear search while statements to code --- Phone.cpp | 4 ++-- Phone.h | 6 +++--- Source.cpp | 50 ++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/Phone.cpp b/Phone.cpp index 9e5b5ee..3ead887 100644 --- a/Phone.cpp +++ b/Phone.cpp @@ -1,9 +1,9 @@ #include #include -#inlcude "Header.h" +#include "Phone.h" using namespace std; -phone::Phone (string n , double c){ +phone::phone (string n , double c){ phoneType= n; phoneCost= c; } diff --git a/Phone.h b/Phone.h index 552f192..f9e39ff 100644 --- a/Phone.h +++ b/Phone.h @@ -5,12 +5,12 @@ using namespace std; class phone{ private: -string type; -double cost; +string phoneType; +double phoneCost; public: -Phone (string = "", double = 0.0); +phone (string = "", double = 0.0); void setPhoneType(string n); string getPhoneType(); void setPhoneCost(double c); diff --git a/Source.cpp b/Source.cpp index 8509388..b32df88 100644 --- a/Source.cpp +++ b/Source.cpp @@ -1,24 +1,50 @@ #include #include #include -#include "Header.h" +#include "Phone.h" using namespace std; +int linearSearch(auto data, auto key); + int main(){ - string type; - double cost; -/* - phone Apple; - phone Samsung; - phone Huawei; - phone Htc; - phone myPhone; -*/ + string type; + string search_key; + double cost; + int answer; + - vector myPhone/*(iPhone, Htc, Samsung , Huawei)*/; - cout<<"Enter a brad of phone" ; + vector myPhone; + cout<<"Enter a brand of phone" ; cin>>type; myPhone.push_back(type); + + while (type != "#"){ + myPhone.push_back(type); + cin>>type; + } + + cout<< "Number of types entered ="<>search_key; + + while(search_key != "#") + { + answer = linearSearch(type,search_key); + + cout<<" '"<>search_key; + } + + + /* cout<<"My vector contains:"< Date: Wed, 8 Feb 2017 12:22:17 -0400 Subject: [PATCH 15/17] Added linear search while statements to code --- Source.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source.cpp b/Source.cpp index b32df88..33c9f35 100644 --- a/Source.cpp +++ b/Source.cpp @@ -4,7 +4,7 @@ #include "Phone.h" using namespace std; -int linearSearch(auto data, auto key); +int linearSearch(auto myPhone, auto key); int main(){ string type; @@ -29,7 +29,7 @@ int main(){ while(search_key != "#") { - answer = linearSearch(type,search_key); + answer = linearSearch(myPhone,search_key); cout<<" '"< Date: Thu, 9 Feb 2017 10:58:28 -0400 Subject: [PATCH 16/17] Fixed errors --- Source.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source.cpp b/Source.cpp index 33c9f35..19317d0 100644 --- a/Source.cpp +++ b/Source.cpp @@ -52,13 +52,12 @@ cout<<"My vector contains:"< Date: Mon, 27 Feb 2017 16:03:26 -0400 Subject: [PATCH 17/17] changed getPhoneCost to setPhoneCost --- Phone.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Phone.h b/Phone.h index f9e39ff..da6e891 100644 --- a/Phone.h +++ b/Phone.h @@ -1,4 +1,4 @@ -#include +s#include #include #include using namespace std; @@ -14,6 +14,6 @@ phone (string = "", double = 0.0); void setPhoneType(string n); string getPhoneType(); void setPhoneCost(double c); - double getPhoneCost(); + double setPhoneCost(); void outputMessage(); };