diff --git a/assingn1/book.h b/assingn1/book.h new file mode 100644 index 0000000..63e2dbc --- /dev/null +++ b/assingn1/book.h @@ -0,0 +1,33 @@ +#include +#include +using namespace std; +#ifndef BOOK_H +#define BOOK_H + +class Book { +private: + string title; + string author; + string isbn; +public: + void setTitle(const string& TITLE) { + title = TITLE; + } + string getTitle() { + return title; + } + void setAuthor(const string& AUTHOR) { + author = AUTHOR; + } + string getAuthor() { + return author; + } + void setIsbn(const string& ISBN) { + isbn = ISBN; + } + string getIsbn() { + return isbn; + } +}; + +#endif \ No newline at end of file diff --git a/assingn1/bookItem.h b/assingn1/bookItem.h new file mode 100644 index 0000000..6693d2a --- /dev/null +++ b/assingn1/bookItem.h @@ -0,0 +1,40 @@ +#include +#include +using namespace std; + +#ifndef BOOKITEM_H +#define BOOKITEM_H + +#include "libraryItem.h" + +class BookItem : public LibraryItem { +private: + string author; + string isbn; + +public: + void setAuthor(const string& AUTHOR) { + author = AUTHOR; + } + string getAuthor() { + return author; + } + void setIsbn(const string& ISBN) { + isbn = ISBN; + } + string getIsbn() { + return isbn; + } + void printDetails() { + getTitle(); + getDueDate(); + getAuthor(); + getIsbn(); + Checkout(); + } + double calculateLateFees(int daysOverdue) { + return daysOverdue * 100.00; + } +}; + +#endif \ No newline at end of file diff --git a/assingn1/library.h b/assingn1/library.h new file mode 100644 index 0000000..7a2a6e9 --- /dev/null +++ b/assingn1/library.h @@ -0,0 +1,61 @@ +#ifndef LIBRARY_H +#define LIBRARY_H +#include +#include "bookItem.h" +#include "patron.h" +#include "patronRecord.h" + +class Library { +private: +std::vector books; +std::vector patrons; +std::vector patronRecords; + +public: + BookItem book; + void searchBooksByTitle( const string& title) { + bool found = false; + for (const auto& BookItem : books) { + if (book.getTitle().find(title) != string::npos) { + book.printDetails(); + found = true; + } + } + if (!found) { + cout << "Book not found" << endl; + } + } + void searchBooksByAuthor( const string& author) { + bool found = false; + for (const auto& BookItem : books) { + if (book.getAuthor().find(author) != string::npos) { + book.printDetails(); + found = true; + } + } + if (!found) { + cout << "Book not found" << endl; + } + } + Patron pat; + PatronRecord pat2; + void searchPatronByName( const string& name) { + bool found = false; + for (const auto& Patron : patrons) { + if (pat.getName().find(name) != string::npos) { + pat.getName(); + pat2.listCheckedOutBooks(); + found = true; + } + } + if (!found) { + cout << "Patron not found" << endl; + } + } + void listOverdueBooks() { + + } +}; + + +#endif \ No newline at end of file diff --git a/assingn1/libraryItem.h b/assingn1/libraryItem.h new file mode 100644 index 0000000..b9f1aea --- /dev/null +++ b/assingn1/libraryItem.h @@ -0,0 +1,53 @@ +#include +#include +using namespace std; +#ifndef LIBRARYITEM_H +#define LIBRARYITEM_H + +class LibraryItem { +private: + string title; + bool isCheckedOut; + string dueDate; + +public: + LibraryItem() : isCheckedOut(false) {} + + void setCheckOut (bool check) { + isCheckedOut = check; + } + bool getCheckOut() const { + return isCheckedOut; + } + void Checkout() { + if (isCheckedOut = false) + { + cout << "Book is Available" << endl; + } else { + cout << "Book is not Available" << endl; + } + } + void returnItem() { + cout << "Item Returned" << endl; + } + void renewItem(int extraDays) { + cout << dueDate << "+ " << extraDays << " Days" << endl; + } + void markAsLost() { + cout << "Item is lost" << endl; + } + void setTitle(const string& TITLE) { + title = TITLE; + } + string getTitle() { + return title; + } + void setDueDate(const string& DUE) { + dueDate = DUE; + } + string getDueDate() { + return dueDate; + } +}; + +#endif \ No newline at end of file diff --git a/assingn1/main.cpp b/assingn1/main.cpp new file mode 100644 index 0000000..ae92812 --- /dev/null +++ b/assingn1/main.cpp @@ -0,0 +1,22 @@ +#include +#include +#include "book.h" +#include "bookItem.h" +#include "library.h" +#include "libraryItem.h" +#include "patron.h" +#include "patronRecord.h" + +int main() +{ + BookItem item; + item.setAuthor("Shasha Wakama"); + item.setIsbn("20222024"); + LibraryItem item; + item.setTitle("Object Oriented Programming"); + item.setDueDate("10"); + Patron pat; + pat.setName("Lecturer"); + pat.setLcn("18012025"); + return 0; +} diff --git a/assingn1/patron.h b/assingn1/patron.h new file mode 100644 index 0000000..fef8b1b --- /dev/null +++ b/assingn1/patron.h @@ -0,0 +1,39 @@ +#include +#include +using namespace std; +#ifndef PATRON_H +#define PATRON_H + +class Patron { +private: + string name; + string lcn; + string contact; +public: + void setName(const string& NAME) { + name = NAME; + } + string getName() { + return name; + } + void setLcn(const string& LCN) { + lcn = LCN; + } + string getLcn() { + return lcn; + } + void updateContactInfo(const string& newContactInfo) { + contact = newContactInfo; + } + string setContactInfo () { + return contact; + } + void canBorrowMoreBooks(int currentBorrowedCount, int maxLimit = 3) { + if (currentBorrowedCount >= maxLimit) + { + cout << "Cannot borrow more books!" << endl; + } + } +}; + +#endif \ No newline at end of file diff --git a/assingn1/patronRecord.h b/assingn1/patronRecord.h new file mode 100644 index 0000000..33da640 --- /dev/null +++ b/assingn1/patronRecord.h @@ -0,0 +1,41 @@ +#include +#include +#include +using namespace std; + +#ifndef PATRONRECORD_H +#define PATRONRECORD_H + +#include "bookItem.h" + +class PatronRecord { +private: + vector checkedOutBooks; + +public: + PatronRecord() : checkedOutBooks() {} + + void addBook(const string& title) { + LibraryItem l_item; + BookItem b_item; + b_item.setAuthor(title); + + checkedOutBooks.emplace_back(l_item.getTitle(),b_item.getAuthor(),b_item.getIsbn(),l_item.getDueDate()); + } + void subBook() { + checkedOutBooks.resize(checkedOutBooks.size() - 4); + } + void listCheckedOutBooks() const { + for (int list : checkedOutBooks) { + cout << "Here is a list of all your checked out books: " << endl; + cout << endl; + cout << list << endl; + } + } + void getBorrowedCount() { + cout << "You have checked out " << checkedOutBooks.size() / 4 << " Books" << endl; + } + +}; + +#endif \ No newline at end of file