-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibraryController.java
More file actions
101 lines (74 loc) · 2.68 KB
/
LibraryController.java
File metadata and controls
101 lines (74 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package controller;
import data.FileDataModel;
import java.util.List;
import model.*;
public class LibraryController {
private Library library;
private FileDataModel fileDataModel;
public LibraryController() {
library = new Library();
fileDataModel = new FileDataModel();
}
public void addUndergraduateStudent(String studentId, String firstName, String lastName, String major,
int enrollmentYear) {
Student student = new UndergraduateStudent(studentId, firstName, lastName, major, enrollmentYear);
library.addStudent(student);
}
public void addGraduateStudent(String studentId, String firstName, String lastName, String major, String supervisor,
String thesisTitle) {
Student student = new GraduateStudent(studentId, firstName, lastName, major, supervisor, thesisTitle);
library.addStudent(student);
}
public Student searchStudent(String studentId) {
return library.searchStudentById(studentId);
}
public void removeStudent(String studentId) {
library.removeStudent(studentId);
}
public List<Student> getAllStudents() {
return library.getAllStudents();
}
public void addBook(String title, String author, String isbn,Category category, int publicationYear) {
Book book=new Book(title, author, isbn,category, publicationYear, false);
library.addBook(book);
}
public void removeBook(String isbn) {
library.removeBook(isbn);
}
public Book searchBookByTitle(String title) {
return library.searchBookByTitle(title);
}
public Book searchBookByISBN(String isbn) {
return library.searchBookByISBN(isbn);
}
public List<Book> getAvailableBooks() {
return library.getAvailableBooks();
}
public void borrowBook(Book book, Student student) {
library.borrowBook(book, student);
}
public void returnBook(Book book) {
library.returnBook(book);
}
public List<Book> getBorrowedBooksByStudent(String studentId) {
return library.getBorrowedBooksByStudent(studentId);
}
public List<Book> getBooksByCategory(String categoryName) {
return library.getBooksByCategory(categoryName);
}
public List<Student> getStudentsByMajor(String major) {
return library.getStudentsByMajor(major);
}
public void saveData() {
fileDataModel.saveBooks(library.getBooks());
fileDataModel.saveCategories(library.getCategories());
fileDataModel.saveLoans(library.getLoans());
fileDataModel.saveStudents(library.getAllStudents());
}
public void loadData() {
library.setBooks(fileDataModel.loadBooks());
library.setCategories(fileDataModel.loadCategories());
library.setLoans(fileDataModel.loadLoans());
library.setStudents(fileDataModel.loadStudents());
}
}