From f793d036259f890f24f5bd7b54537b14701abd6a Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 19 May 2025 15:47:44 +0330 Subject: [PATCH 1/2] Book is finished --- src/model/Book.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/model/Book.java b/src/model/Book.java index 1191b14..af409b7 100644 --- a/src/model/Book.java +++ b/src/model/Book.java @@ -8,17 +8,18 @@ public class Book { private boolean isBorrowed; public void borrowBook() { - // TODO: Implement method 'borrowBook'. - throw new UnsupportedOperationException("Unimplemented method 'borrowBook'"); + this.isBorrowed=true; } public void returnBook() { - // TODO: Implement method 'returnBook'. - throw new UnsupportedOperationException("Unimplemented method 'returnBook'"); + this.isBorrowed=false; } - public void getDetails() { - // TODO: Implement method 'getDetails'. - throw new UnsupportedOperationException("Unimplemented method 'getDetails'"); - } + public void getDetails(String title,String author,String isbn,int publicationYear,boolean isBorrowed) { + this.title=title; + this.author=author; + this.isbn=isbn; + this.publicationYear=publicationYear; + this.isBorrowed=isBorrowed; + } } From 2471d8b9f5c11544dc72a9d467b5215a25262e08 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 19 May 2025 16:19:17 +0330 Subject: [PATCH 2/2] Book fixed --- src/model/Book.java | 23 +++++++++++++++-------- src/model/Category.java | 18 ++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/model/Book.java b/src/model/Book.java index af409b7..ddd15a1 100644 --- a/src/model/Book.java +++ b/src/model/Book.java @@ -7,6 +7,15 @@ public class Book { private int publicationYear; private boolean isBorrowed; + +//Constructor + public Book(String title,String author,String isbn,int publicationYear,boolean isBorrowed){ + this.title=title; + this.author=author; + this.isbn=isbn;this.publicationYear=publicationYear; + this.isBorrowed=isBorrowed; + } +//Setter public void borrowBook() { this.isBorrowed=true; } @@ -14,12 +23,10 @@ public void borrowBook() { public void returnBook() { this.isBorrowed=false; } - - public void getDetails(String title,String author,String isbn,int publicationYear,boolean isBorrowed) { - this.title=title; - this.author=author; - this.isbn=isbn; - this.publicationYear=publicationYear; - this.isBorrowed=isBorrowed; - } +//Getter + public String getTitle() {return this.title;} + public String getAuthor() {return this.author;} + public String getIsbn() {return this.isbn;} + public Integer getPublicationYear() {return this.publicationYear;} + public boolean getIsBorrowed() {return this.isBorrowed;} } diff --git a/src/model/Category.java b/src/model/Category.java index 81700eb..e1e52ac 100644 --- a/src/model/Category.java +++ b/src/model/Category.java @@ -3,14 +3,16 @@ public class Category { private String name; private String description; - - public void getName() { - // TODO: Implement method 'getName'. - throw new UnsupportedOperationException("Unimplemented method 'getName'"); +//Constructor + public Category(String name,String description){ + this.name=name; + this.description=description; } - - public void getDescription() { - // TODO: Implement method 'getDescription'. - throw new UnsupportedOperationException("Unimplemented method 'getDescription'"); +//Getter + public String getName() { + return this.name; + } + public String getDescription() { + return this.description; } }