diff --git a/hellogit.out b/hellogit.out new file mode 100644 index 0000000..32f7f3b Binary files /dev/null and b/hellogit.out differ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..d8c7c07 --- /dev/null +++ b/main.cpp @@ -0,0 +1,98 @@ +#include +#include +#include "test.h" +#include +using namespace std; + + +int linearSearch(vector A, string key, char aChar) { + + + for(int i = 0; i < A.size(); i ++) { + + if (A[i].getString() == key){ + return i; + + } + + if (A[i].getChar() == aChar){ + return i; + } + + } + return -1; +} + + +int main (){ + string input = ""; + char xChar = 'c'; + string string1 = ""; + int xnum1 = 0; + int xnum2 = 0; + char xChar2 = 'p'; + char xChar3 = '\0'; + Test testObj; // object + Test testObj2; + Test testObj3; + Test testObj4; + vector objVect; + + cout << "Enter 3 characters and a string: " << endl; + cin >> xChar; + cin >> xChar2; + cin >> xChar3; + cin >> string1; + + + + + + //testObj.setVect(xChar, string1, xnum1, xnum2); + //objVect.push_back(testObj); + + testObj.setChar(xChar3); + testObj2.setChar(xChar); + testObj3.setVect(xChar, string1); + testObj4.setChar(xChar2); + + objVect.push_back(testObj); + objVect.push_back(testObj3); + + objVect.push_back(testObj2); + objVect.push_back(testObj4); + + + + for(int x = 0; x < objVect.size(); x++) { + + cout << objVect[x].getString(); + + + cout << objVect[x].getChar() << endl; + + + } + char hChar = '\0'; + int result = 0; + while(cin >> input >> hChar)//perform searches until Ctrl + D entered + { + + result = linearSearch(objVect, input, hChar); + + cout<<" "<< input <<" was "; + + if (result == -1) + cout<<"not found"; + else + cout<<"found at position "<< result; + + + cout< +#include "test.h" +#include + +Test::Test(){ +char char1 = '\0'; +string sent = ""; +string stri = ""; +char cha = '\0'; +int number1 = 0; +int number2 = 0; + + +} + + +void Test::setChar(char char1) { + + cha = char1; + } + +char Test::getChar(){ + return cha; + + } + + +void Test::setString(string sent) { + + stri = sent; + } + +string Test::getString(){ + return stri; + + } + + + +void Test::setVect(char ch, string sent){ + cha = ch; + stri = sent; + + } + + diff --git a/test.h b/test.h new file mode 100644 index 0000000..5fe7040 --- /dev/null +++ b/test.h @@ -0,0 +1,32 @@ +#include +#include +#include +#ifndef TEST_H +#define TEST_H +using namespace std; + +class Test{ + private: + + char cha; + string stri; + //vector objVect (char, string); + + public: + + void setChar(char char1); + char getChar(); + + void setString (string sent); + string getString(); + + //void setRep(char ch, string strin); + + + + void setVect(char ch, string sent); + Test(); + +}; + +#endif