Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added Librarian Concept + Media support #294

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,22 @@
package com.codedifferently.lesson10.library;

import com.codedifferently.lesson10.library.media.Dvd;
import java.util.List;

public class Librarian extends Patron {
00USER1X marked this conversation as resolved.
Show resolved Hide resolved
private List<Dvd> dvds;

public Librarian(String id, String name) {
super(id, name); // Updated constructor call with two arguments
}

public void addDvd(Dvd dvd) {
dvds.add(dvd);
}

public void removeDvd(Dvd dvd) {
dvds.remove(dvd);
}

// Additional methods and properties specific to Librarians
}
Expand Up @@ -12,6 +12,7 @@ public class Library {
private Set<String> checkedOutIsbns = new HashSet<>();
private Map<String, Set<Book>> checkedOutBooksByPatron = new HashMap<>();
private Set<String> patronIds = new HashSet<>();
private Set<String> dvdIds = new HashSet<>(); // Added for DVDs
private String id;

/**
Expand Down Expand Up @@ -176,6 +177,6 @@ public String toString() {
+ checkedOutBooksByPatron
+ ", patronIds="
+ patronIds
+ '}';
+ "}";
}
}
Expand Up @@ -59,6 +59,36 @@ public Set<Book> getCheckedOutBooks() throws LibraryNotSetException {
return this.library.getCheckedOutByPatron(this);
}

/**
* Check out a book from the library.
*
* @param book The book to check out.
* @return True if the book was successfully checked out, false otherwise.
*/
public boolean checkOutBook(Book book) {
try {
return this.library.checkOutBook(book, this);
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
}

/**
* Return a book to the library.
*
* @param book The book to return.
* @return True if the book was successfully returned, false otherwise.
*/
public boolean checkInBook(Book book) {
try {
return this.library.checkInBook(book, this);
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
@@ -0,0 +1,10 @@
package com.codedifferently.lesson10.library.media;

import com.codedifferently.lesson10.library.Book;
import java.util.List;

public class Dvd extends Book {
public Dvd(String id, String title, List<String> authors, int year) {
super(id, title, authors, year); // Updated constructor call with four arguments
}
}
@@ -0,0 +1,25 @@
package com.codedifferently.lesson10.library.media;

public class Magazine {
private String title;
private String issueNumber;
private String publicationDate;

public Magazine(String title, String issueNumber, String publicationDate) {
this.title = title;
this.issueNumber = issueNumber;
this.publicationDate = publicationDate;
}

public String getTitle() {
return title;
}

public String getIssueNumber() {
return issueNumber;
}

public String getPublicationDate() {
return publicationDate;
}
}
@@ -0,0 +1,25 @@
package com.codedifferently.lesson10.library.media;

public class Newspaper {
private String title;
private String edition;
private String publicationDate;

public Newspaper(String title, String edition, String publicationDate) {
this.title = title;
this.edition = edition;
this.publicationDate = publicationDate;
}

public String getTitle() {
return title;
}

public String getEdition() {
return edition;
}

public String getPublicationDate() {
return publicationDate;
}
}
@@ -0,0 +1 @@

@@ -0,0 +1 @@

@@ -0,0 +1 @@