Skip to content

Commit 2f54b7b

Browse files
authored
Merge pull request #7 from fndrmh/Book_1
Implement constructor and getters for Book & Category
2 parents 82ef615 + 729e26a commit 2f54b7b

2 files changed

Lines changed: 27 additions & 17 deletions

File tree

src/model/Book.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@ public class Book {
77
private int publicationYear;
88
private boolean isBorrowed;
99

10+
11+
//Constructor
12+
public Book(String title,String author,String isbn,int publicationYear,boolean isBorrowed){
13+
this.title=title;
14+
this.author=author;
15+
this.isbn=isbn;this.publicationYear=publicationYear;
16+
this.isBorrowed=isBorrowed;
17+
}
18+
//Setter
1019
public void borrowBook() {
11-
// TODO: Implement method 'borrowBook'.
12-
throw new UnsupportedOperationException("Unimplemented method 'borrowBook'");
20+
this.isBorrowed=true;
1321
}
1422

1523
public void returnBook() {
16-
// TODO: Implement method 'returnBook'.
17-
throw new UnsupportedOperationException("Unimplemented method 'returnBook'");
18-
}
19-
20-
public void getDetails() {
21-
// TODO: Implement method 'getDetails'.
22-
throw new UnsupportedOperationException("Unimplemented method 'getDetails'");
24+
this.isBorrowed=false;
2325
}
26+
//Getter
27+
public String getTitle() {return this.title;}
28+
public String getAuthor() {return this.author;}
29+
public String getIsbn() {return this.isbn;}
30+
public Integer getPublicationYear() {return this.publicationYear;}
31+
public boolean getIsBorrowed() {return this.isBorrowed;}
2432
}

src/model/Category.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
public class Category {
44
private String name;
55
private String description;
6-
7-
public void getName() {
8-
// TODO: Implement method 'getName'.
9-
throw new UnsupportedOperationException("Unimplemented method 'getName'");
6+
//Constructor
7+
public Category(String name,String description){
8+
this.name=name;
9+
this.description=description;
1010
}
11-
12-
public void getDescription() {
13-
// TODO: Implement method 'getDescription'.
14-
throw new UnsupportedOperationException("Unimplemented method 'getDescription'");
11+
//Getter
12+
public String getName() {
13+
return this.name;
14+
}
15+
public String getDescription() {
16+
return this.description;
1517
}
1618
}

0 commit comments

Comments
 (0)