From ece9cfae9af23f96cf31c257c8c80b4ab8be0bee Mon Sep 17 00:00:00 2001 From: Blossomvc Date: Tue, 24 Jan 2017 11:15:19 -0400 Subject: [PATCH 1/7] Added header file --- Books.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Books.h diff --git a/Books.h b/Books.h new file mode 100644 index 0000000..d2b8570 --- /dev/null +++ b/Books.h @@ -0,0 +1,28 @@ +#include + +class Books +{ + public: + Books() + { + fee=0; + } + + + void setName(string member) + { + name=member; + } + + + float getBalance(int numDays) + { + rate=0.10; + fee=numDays * rate; + return fee; + } + + private: + string name, float fee, float rate; + +}; From 14e28477bdb490da971ba11413a057e673d79df4 Mon Sep 17 00:00:00 2001 From: Blossomvc Date: Tue, 24 Jan 2017 11:29:25 -0400 Subject: [PATCH 2/7] Added implementation file --- Library.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Library.cpp diff --git a/Library.cpp b/Library.cpp new file mode 100644 index 0000000..e69de29 From 9bad592d203928e88e6c2c1166bba25cd46fc003 Mon Sep 17 00:00:00 2001 From: Blossomvc Date: Tue, 24 Jan 2017 11:30:28 -0400 Subject: [PATCH 3/7] Added implementation file --- Library.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Library.cpp b/Library.cpp index e69de29..2788b71 100644 --- a/Library.cpp +++ b/Library.cpp @@ -0,0 +1,25 @@ +#include +#include +#include "Books.h" +using namespace std; + +int main() +{ + vectorbooks; + string member; + int j; + + for (int x=0; x<4; x++) + { + cout<<"Please enter the members with overdue books"; + cin>>member; + books[x].setName(member); + + cout<<"Please enter the number of days late"; + cin>>j; + + cout< Date: Tue, 24 Jan 2017 11:58:21 -0400 Subject: [PATCH 4/7] Add client file --- Books.cpp | 30 ++++++++++++++++++++++++++++++ Books.h | 30 +++++++++++++----------------- 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 Books.cpp diff --git a/Books.cpp b/Books.cpp new file mode 100644 index 0000000..4125bce --- /dev/null +++ b/Books.cpp @@ -0,0 +1,30 @@ +#include "Books.h" +#include + +Books:: Books() +{ + fee=0; +} + +void Books::setName(string member) +{ + name=member; +} + +string Books::getName() +{ + return name; +} + + +void Books::setFee(int numDays) +{ + + fee=numDays * 0.1; + +} + +float Books::getFee() +{ + return fee; +} diff --git a/Books.h b/Books.h index d2b8570..8ea4a98 100644 --- a/Books.h +++ b/Books.h @@ -1,28 +1,24 @@ -#include class Books { public: - Books() - { - fee=0; - } + Books(); + + void setName(); + + string getName(); + + void setFee(); + + float getFee(); + - void setName(string member) - { - name=member; - } - - float getBalance(int numDays) - { - rate=0.10; - fee=numDays * rate; - return fee; - } private: - string name, float fee, float rate; + string name; + float fee; + }; From 7a070762db579dcc7160c10933b4bc82e13703e5 Mon Sep 17 00:00:00 2001 From: Blossomvc Date: Tue, 24 Jan 2017 12:07:30 -0400 Subject: [PATCH 5/7] Changed for-loops in client file --- Library.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library.cpp b/Library.cpp index 2788b71..bb1435d 100644 --- a/Library.cpp +++ b/Library.cpp @@ -18,7 +18,12 @@ int main() cout<<"Please enter the number of days late"; cin>>j; - cout< Date: Tue, 7 Feb 2017 12:03:52 -0400 Subject: [PATCH 6/7] LinearSearch changes to hellogit --- Books.cpp | 5 ++++- Books.h | 8 ++++++-- Library.cpp | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Books.cpp b/Books.cpp index 4125bce..01f5344 100644 --- a/Books.cpp +++ b/Books.cpp @@ -1,7 +1,8 @@ #include "Books.h" #include +using namespace std; -Books:: Books() +Books::Books() { fee=0; } @@ -28,3 +29,5 @@ float Books::getFee() { return fee; } + + diff --git a/Books.h b/Books.h index 8ea4a98..f290a78 100644 --- a/Books.h +++ b/Books.h @@ -1,17 +1,21 @@ +#include +using namespace std; + class Books { public: Books(); - void setName(); + void setName(string); string getName(); - void setFee(); + void setFee(int); float getFee(); + diff --git a/Library.cpp b/Library.cpp index bb1435d..a855bc2 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1,11 +1,14 @@ #include #include #include "Books.h" +#include using namespace std; int main() { + vectorbooks; + Books member; string member; int j; @@ -13,12 +16,14 @@ int main() { cout<<"Please enter the members with overdue books"; cin>>member; - books[x].setName(member); - + //books[x].setName(member); + books.push_back(books); + cout<<"Please enter the number of days late"; cin>>j; books[x].setFee(j); + //books.push_back(j); } for (int x=0; x<4; x++) @@ -26,5 +31,28 @@ int main() cout<>"key was not found">>endl; + } + else + cout>>"key found at">> num; + */ return 0; } + +/* +int linearSearch (auto Data,auto key) +{ + for(int i=0; i Date: Tue, 14 Feb 2017 00:19:02 -0400 Subject: [PATCH 7/7] Corrected linearSearch funciton in files --- Books.cpp | 14 +++++++-- Books.h | 21 ++++++++++---- Library.cpp | 82 +++++++++++++++++++++++++++++++++++------------------ 3 files changed, 81 insertions(+), 36 deletions(-) diff --git a/Books.cpp b/Books.cpp index 01f5344..da456ba 100644 --- a/Books.cpp +++ b/Books.cpp @@ -1,5 +1,6 @@ #include "Books.h" #include +#include using namespace std; Books::Books() @@ -7,12 +8,19 @@ Books::Books() fee=0; } +Books::Books(string member, int numDays) +{ + name=member; + + fee=numDays * 0.50; +} + void Books::setName(string member) { name=member; } -string Books::getName() +string Books::getName() const { return name; } @@ -21,11 +29,11 @@ string Books::getName() void Books::setFee(int numDays) { - fee=numDays * 0.1; + fee=numDays * 0.50; } -float Books::getFee() +double Books::getFee() const { return fee; } diff --git a/Books.h b/Books.h index f290a78..92cb46e 100644 --- a/Books.h +++ b/Books.h @@ -1,28 +1,37 @@ -#include -using namespace std; +#ifndef BOOKS_H +#define BOOKS_H + +#include +#include + +using namespace std; class Books { + public: Books(); + + Books(string, int); void setName(string); - string getName(); + string getName() const; void setFee(int); - float getFee(); + double getFee() const; - private: string name; - float fee; + double fee; }; + +#endif diff --git a/Library.cpp b/Library.cpp index a855bc2..310c271 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1,58 +1,86 @@ #include +#include #include +#include + #include "Books.h" -#include + using namespace std; +int linearSearch(vector&, string); + int main() { - vectorbooks; - Books member; + vectorObooks; //vector of object overdue books + string member; - int j; + int days,amt,num; - for (int x=0; x<4; x++) + cout<<"\nPlease enter the following information for overdue books"; + cout<<"\n How many late members are there? "; + cin>>amt; + + for (int x=0; x>member; - //books[x].setName(member); - books.push_back(books); - cout<<"Please enter the number of days late"; - cin>>j; + cout<<"Please enter the number of days late: "; + cin>>days; + + Books lateMembers(member,days); - books[x].setFee(j); - //books.push_back(j); + Obooks.push_back(lateMembers); + + cout<>"key was not found">>endl; + cout<<"Please enter a name to be searched(to end input,enter '!'): "; + cin>>value; + + while(value != "!") + { + num= linearSearch(Obooks,value); + + if (num==-1) + { + cout<<"Name was not found"<>value; + } - else - cout>>"key found at">> num; - */ + + return 0; } -/* -int linearSearch (auto Data,auto key) + +int linearSearch (vector& Data, string key) { - for(int i=0; i