diff --git a/Account.cpp b/Account.cpp new file mode 100644 index 0000000..996f3af --- /dev/null +++ b/Account.cpp @@ -0,0 +1,28 @@ +#include +#include +#include "Account.h" + +using namespace std; + +Account::Account( ) +{ + name = ""; + acct_num = 0; +} +void Account::setName (string accountName) +{ + name = accountName; +} +string Account:: getName ( ) +{ + return name; +} +void Account::setNum (int a) +{ + acct_num = a; +} +int Account::getNum ( ) +{ + return acct_num; +} + diff --git a/Account.h b/Account.h new file mode 100644 index 0000000..f189f72 --- /dev/null +++ b/Account.h @@ -0,0 +1,21 @@ +#ifndef ACCOUNT_H +#define ACCOUNT_H +#include +#include +using namespace std; + +class Account +{ + private: + string name; + int acct_num; + + public: + Account ( ); + void setName (string); + string getName ( ); + void setNum (int); + int getNum ( ); +}; +#endif + diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..365af41 --- /dev/null +++ b/Main.cpp @@ -0,0 +1,57 @@ +#include "Account.cpp" +#include +#include + +using namespace std; + +int linearSearch(auto data, auto key) + { + for (int i=0; i acctList; + + myAccount.setName ("Bob"); + myAccount.setNum (12); + acctList.push_back (myAccount); + myAccount.setName ("Tim"); + myAccount.setNum (10); + acctList.push_back(myAccount); + myAccount.setName ("Rich"); + myAccount.setNum (35); + acctList.push_back (myAccount); + myAccount.setName ("Chris"); + myAccount.setNum (66); + acctList.push_back (myAccount); + + /*for (int i = 0; i < acctList.size ( ); i++) + { + cout << acctList[i].getName()<< "" << acctList[i].getNum (); + + }*/ + + cout << "Enter search key: "; + cin >> search_key; + + result = linearSearch(acctList, search_key); + + if (result == -1) + cout<<"not found"; + else + cout<<"found at index "<