Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions assingn1/book.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <string>
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
40 changes: 40 additions & 0 deletions assingn1/bookItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <string>
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
61 changes: 61 additions & 0 deletions assingn1/library.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef LIBRARY_H
#define LIBRARY_H
#include <vector>
#include "bookItem.h"
#include "patron.h"
#include "patronRecord.h"

class Library {
private:
std::vector<BookItem> books;
std::vector<Patron> patrons;
std::vector<PatronRecord> 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
53 changes: 53 additions & 0 deletions assingn1/libraryItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <string>
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
22 changes: 22 additions & 0 deletions assingn1/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <vector>
#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;
}
39 changes: 39 additions & 0 deletions assingn1/patron.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <string>
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
41 changes: 41 additions & 0 deletions assingn1/patronRecord.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#ifndef PATRONRECORD_H
#define PATRONRECORD_H

#include "bookItem.h"

class PatronRecord {
private:
vector<int> 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