diff --git a/Phone.cpp b/Phone.cpp new file mode 100644 index 0000000..3ead887 --- /dev/null +++ b/Phone.cpp @@ -0,0 +1,30 @@ +#include +#include +#include "Phone.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; + } diff --git a/Phone.h b/Phone.h new file mode 100644 index 0000000..da6e891 --- /dev/null +++ b/Phone.h @@ -0,0 +1,19 @@ +s#include +#include +#include +using namespace std; + +class phone{ +private: +string phoneType; +double phoneCost; + + +public: +phone (string = "", double = 0.0); + void setPhoneType(string n); + string getPhoneType(); + void setPhoneCost(double c); + double setPhoneCost(); + void outputMessage(); +}; diff --git a/Source.cpp b/Source.cpp new file mode 100644 index 0000000..19317d0 --- /dev/null +++ b/Source.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include "Phone.h" +using namespace std; + +int linearSearch(auto myPhone, auto key); + +int main(){ + string type; + string search_key; + double cost; + int answer; + + + 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(myPhone,search_key); + + cout<<" '"<>search_key; + } + + + +/* +cout<<"My vector contains:"<