BÀI TOÁN QUẢN LÝ THƯ VIỆN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

BÀI TOÁN QUẢN LÝ THƯ VIỆN

1. Đối tượng Account (Account.java) ....................................................................................................................... 2


2. Đối tượng Book (Book.java) ................................................................................................................................. 5
3. Đối tượng BookRequest (BookRequest.java) ....................................................................................................... 8
4. Đối tượng Librarian (Librarian.java) .................................................................................................................. 10
5. Đối tượng Member (Member.java) ..................................................................................................................... 13
6. Lớp Node (Node.java) ......................................................................................................................................... 16
7. Lớp MyList (MyList.java) .................................................................................................................................. 18
8. Lớp Main (Main.java) ......................................................................................................................................... 25
1. Đối tượng Account (Account.java)

import java.util.Objects;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/

public class Account {


String accountID;
String accountType;
String fullName, date, phoneNumber, email, address;
String status;

public Account() {
}

public Account(String accountID, String accountType, String fullName, String date, String phoneNumber, String
email, String address, String status) {
this.accountID = accountID;
this.accountType = accountType;
this.fullName = fullName;
this.date = date;
this.phoneNumber = phoneNumber;
this.email = email;
this.address = address;
this.status = status;
}

public String getAccountID() {


return accountID;
}
public void setAccountID(String accountID) {
this.accountID = accountID;
}

public String getAccountType() {


return accountType;
}

public void setAccountType(String accountType) {


this.accountType = accountType;
}

public String getFullName() {


return fullName;
}

public void setFullName(String fullName) {


this.fullName = fullName;
}

public String getDate() {


return date;
}

public void setDate(String date) {


this.date = date;
}

public String getPhoneNumber() {


return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {


this.phoneNumber = phoneNumber;
}

public String getEmail() {


return email;
}

public void setEmail(String email) {


this.email = email;
}

public String getAddress() {


return address;
}

public void setAddress(String address) {


this.address = address;
}

public String getStatus() {


return status;
}

public void setStatus(String status) {


this.status = status;
}

@Override
public int hashCode() {
return super.hashCode();
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Account other = (Account) obj;
return Objects.equals(this.accountID, other.accountID);
}

}
2. Đối tượng Book (Book.java)

import java.util.Objects;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/
public class Book {
String ISBN, title, authors, year, publisher, status;

public Book() {
}

public Book(String ISBN, String title, String authors, String year, String publisher, String status) {
this.ISBN = ISBN;
this.title = title;
this.authors = authors;
this.year = year;
this.publisher = publisher;
this.status = status;
}

public Book(String ISBN) {


this.ISBN = ISBN;
}

public String getISBN() {


return ISBN;
}

public void setISBN(String ISBN) {


this.ISBN = ISBN;
}

public String getTitle() {


return title;
}
public void setTitle(String title) {
this.title = title;
}

public String getAuthors() {


return authors;
}

public void setAuthors(String authors) {


this.authors = authors;
}

public String getYear() {


return year;
}

public void setYear(String year) {


this.year = year;
}

public String getPublisher() {


return publisher;
}

public void setPublisher(String publisher) {


this.publisher = publisher;
}

public String getStatus() {


return status;
}

public void setStatus(String status) {


this.status = status;
}

@Override
public String toString() { //Format chỉnh theo cá nhân
return ISBN + " " + title + " " + authors + " " + year + " " + publisher + " " + status;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Book other = (Book) obj;
return Objects.equals(this.ISBN, other.ISBN);
}

}
3. Đối tượng BookRequest (BookRequest.java)

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/
public class BookRequest{
String blCode, memberID, ISBN, dueDate, returnDate;

public BookRequest() {
}

public BookRequest(String blCode, String memberID, String ISBN, String dueDate, String returnDate) {
this.blCode = blCode;
this.memberID = memberID;
this.ISBN = ISBN;
this.dueDate = dueDate;
this.returnDate = returnDate;
}

public String getBlCode() {


return blCode;
}

public void setBlCode(String blCode) {


this.blCode = blCode;
}

public String getDueDate() {


return dueDate;
}

public void setDueDate(String dueDate) {


this.dueDate = dueDate;
}

public String getReturnDate() {


return returnDate;
}

public void setReturnDate(String returnDate) {


this.returnDate = returnDate;
}

public String getMemberID() {


return memberID;
}

public void setMemberID(String memberID) {


this.memberID = memberID;
}

public String getISBN() {


return ISBN;
}

public void setISBN(String ISBN) {


this.ISBN = ISBN;
}

@Override
public String toString() { //Format chỉnh theo cá nhân
return blCode + " " + memberID + " " + ISBN + " " + dueDate + " " + returnDate;
}

}
4. Đối tượng Librarian (Librarian.java)

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/
public class Librarian extends Account {

String startingDate, martitalStatus;

public Librarian() {
}

public Librarian(String accountID, String accountType, String fullName, String date, String phoneNumber, String
email, String address, String status, String startingDate, String martitalStatus) {
super(accountID, accountType, fullName, date, phoneNumber, email, address, status);
this.startingDate = startingDate;
this.martitalStatus = martitalStatus;
}

public String getStartingDate() {


return startingDate;
}

public void setStartingDate(String startingDate) {


this.startingDate = startingDate;
}

public String getMartitalStatus() {


return martitalStatus;
}

public void setMartitalStatus(String martitalStatus) {


this.martitalStatus = martitalStatus;
}

public String getAccountID() {


return accountID;
}
public void setAccountID(String accountID) {
this.accountID = accountID;
}

public String getFullName() {


return fullName;
}

public void setFullName(String fullName) {


this.fullName = fullName;
}

public String getDate() {


return date;
}

public void setDate(String date) {


this.date = date;
}

public String getPhoneNumber() {


return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {


this.phoneNumber = phoneNumber;
}

public String getEmail() {


return email;
}

public void setEmail(String email) {


this.email = email;
}

public String getAddress() {


return address;
}

public void setAddress(String address) {


this.address = address;
}

public String getAccountType() {


return accountType;
}

public void setAccountType(String accountType) {


this.accountType = accountType;
}

public String getStatus() {


return status;
}

public void setStatus(String status) {


this.status = status;
}

@Override
public String toString() { //Format chỉnh theo cá nhân
return accountID + " " + accountType + " " + fullName + " " + date + " " + phoneNumber + " " + email + " " +
address + " " + status + " " + startingDate + " " + martitalStatus;
}

}
5. Đối tượng Member (Member.java)

import java.util.Objects;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/
public class Member extends Account{
String memberShipDate;
int nBook;

public Member() {
}

public Member(String memberShipDate, int nBook) {


this.memberShipDate = memberShipDate;
this.nBook = nBook;
}

public Member(String memberShipDate, int nBook, String accountID, String accountType, String fullName,
String date, String phoneNumber, String email, String address, String status) {
super(accountID, accountType, fullName, date, phoneNumber, email, address, status);
this.memberShipDate = memberShipDate;
this.nBook = nBook;
}

public String getMemberShipDate() {


return memberShipDate;
}

public void setMemberShipDate(String memberShipDate) {


this.memberShipDate = memberShipDate;
}
public int getnBook() {
return nBook;
}

public void setnBook(int nBook) {


this.nBook = nBook;
}

public String getAccountID() {


return accountID;
}

public void setAccountID(String accountID) {


this.accountID = accountID;
}

public String getAccountType() {


return accountType;
}

public void setAccountType(String accountType) {


this.accountType = accountType;
}

public String getFullName() {


return fullName;
}

public void setFullName(String fullName) {


this.fullName = fullName;
}

public String getDate() {


return date;
}

public void setDate(String date) {


this.date = date;
}

public String getPhoneNumber() {


return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {


this.phoneNumber = phoneNumber;
}

public String getEmail() {


return email;
}

public void setEmail(String email) {


this.email = email;
}

public String getAddress() {


return address;
}

public void setAddress(String address) {


this.address = address;
}

public String getStatus() {


return status;
}

public void setStatus(String status) {


this.status = status;
}

@Override
public String toString() { //Format chỉnh theo cá nhân
return accountID + " " + accountType + " " + fullName + " " + date + " " + phoneNumber + " " + email + " " +
address + " " + status + " " + memberShipDate + " " + nBook;
}

}
6. Lớp Node (Node.java)

import java.util.Objects;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/

/**
*
* @author ducbao
*/
public class Node<T> {
private T info;
private Node<T> next;

public Node() {
}

public Node(T info) {


this.info = info;
this.next = null;
}

public T getInfo() {
return info;
}

public void setInfo(T info) {


this.info = info;
}

public Node<T> getNext() {


return next;
}

public void setNext(Node<T> next) {


this.next = next;
}
@Override
public int hashCode() {
int hash = 7;
hash = 83 * hash + Objects.hashCode(this.info);
hash = 83 * hash + Objects.hashCode(this.next);
return hash;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Node<T> other = (Node<T>) obj;
return true;
}

}
7. Lớp MyList (MyList.java)

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Scanner;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author ducbao
* @param <T> the type of the value
*/
public class MyList<T> {

private Node<T> head;


private Node<T> tail;
Scanner sc = new Scanner(System.in);

public boolean isEmpty() {


return head == null;
}

/*Chèn node vào đầu danh sách*/


public void insertHead(T data) {
Node<T> node = new Node<>(data);
if (isEmpty()) { //Nếu danh sách rỗng
head = tail = node; //Node mới đứng đầu danh sách
} else {
node.setNext(this.head); //Nếu không
this.head = node; //Cho node mới thành node đầu danh sách
}
}

public void insertTail(T data) {


Node<T> node = new Node<>(data);
if (isEmpty()) {
head = tail = node;
} else {
tail.setNext(node);
tail = node;
}
}

/*Search item by data*/


public Node<T> search(String data) {
for (Node<T> p = head; p != null; p = p.getNext()) { //Duyệt danh sách
String line = String.valueOf(p.getInfo());
String txt[] = line.split(" "); //Lấy chuỗi từ 1 node trong danh sách
for (int i = 0; i < txt.length; i++) {
if (data.equals(txt[i])) { //So sánh phần tử cần tìm với phần tử trong chuỗi
return p;
}
}
}
return null;
}

public void searchMember(String data) {


boolean check = false;
for (Node<T> p = head; p != null; p = p.getNext()) { //Duyệt danh sách
String line = String.valueOf(p.getInfo());
String txt[] = line.split(" "); //Lấy chuỗi từ 1 node trong danh sách
for (int i = 0; i < txt.length; i++) {
if (data.equals(txt[i])) { //So sánh phần tử cần tìm với phần tử trong chuỗi
System.out.println(p.getInfo());
check = true;
}
}
if (!check) {
System.out.println("Member didn't borrow book");
}

}
}

/*Kiểm tra trong list có dữ liệu cần tìm hay không


Có trả về true không có trả về false
*/
public boolean compare(String data) {
for (Node<T> p = head; p != null; p = p.getNext()) { //Duyệt danh sách
String line = String.valueOf(p.getInfo());
String txt[] = line.split(" "); //Lấy chuỗi từ 1 node trong danh sách
for (int i = 0; i < txt.length; i++) {
if (data.equals(txt[i])) { //So sánh phần tử cần tìm với phần tử trong chuỗi
return true;
}
}
}
return false;
}

public void clear() {


head = null;
}

/*Đọc file chứa dữ liệu của Member*/


public MyList<T> readFileMember(String fileName, MyList<T> list) {
try {
FileReader flr = new FileReader(fileName);
BufferedReader blr = new BufferedReader(flr);
String line = "";
while (true) {
line = blr.readLine();
if (line == null) {
break;
}
String txt[] = line.split(" ");
String id = txt[0];
String type = txt[1];
String name = txt[2];
String date = txt[3];
String phone = txt[4];
String mail = txt[5];
String address = txt[6];
String status = txt[7];
String memberShipDateString = txt[8];
int nBook = Integer.parseInt(txt[9]);
Member newMember = new Member(memberShipDateString, nBook, id, type, name, date, phone, mail,
address, status);

list.insertTail((T) newMember);
}
flr.close();
blr.close();
} catch (Exception e) {
}
return list;
}
/*Đọc file chứa dữ liệu của Librarian*/
public MyList<T> readFileLibrarian(String fileName, MyList<T> list) {
try {
FileReader flr = new FileReader(fileName);
BufferedReader blr = new BufferedReader(flr);
String line = "";
while (true) {
line = blr.readLine(); //Đọc dữ liệu file theo từng hàng
if (line == null) { //Hết dữ liệu DỪNG VÒNG LẶP (không phải dừng phương thức)
break;
}
String txt[] = line.split(" "); //Tách dòng đã đọc theo kí tự khoảng trắng
String id = txt[0]; //Mỗi phần tử được tách = một dữ liệu của từng phần tử trong danh sách
String type = txt[1];
String name = txt[2];
String date = txt[3];
String phone = txt[4];
String mail = txt[5];
String address = txt[6];
String status = txt[7];
String startingDate = txt[8];
String martitalStatus = txt[9];

/*
* Tạo 1 đối tượng mới cho đối tượng Librarian
* Thêm đối tượng mới vào danh sách CỦA ĐỐI TƯỢNG LIBRARIAN
*/
Librarian newLibrarian = new Librarian(id, type, name, date, phone, mail, address, status, startingDate,
martitalStatus);
list.insertTail((T) newLibrarian);
}
flr.close();
blr.close();
} catch (Exception e) {
}
return list;
}

/*Đọc file chứa dữ liệu của BookRequest*/


public MyList<T> readFileBook(String fileName, MyList<T> list) {
try {
FileReader flr = new FileReader(fileName);
BufferedReader blr = new BufferedReader(flr);
String line = "";
while (true) {
line = blr.readLine();
if (line == null) {
break;
}
String txt[] = line.split(" ");
String id = txt[0];
String title = txt[1];
String author = txt[2];
String year = txt[3];
String publisher = txt[4];
String status = "Available";
Book newBook = new Book(id, title, author, year, publisher, status);
list.insertTail((T) newBook);
}
flr.close();
blr.close();
} catch (Exception e) {
}
return list;
}

/*Đọc file chứa dữ liệu của Book*/


public MyList<T> readFileBookRequest(String fileName, MyList<T> list) {
try {
FileReader flr = new FileReader(fileName);
BufferedReader blr = new BufferedReader(flr);
String line = "";
while (true) {
line = blr.readLine();
if (line == null) {
break;
}
String txt[] = line.split(" ");
String blCode = txt[0];
String memberID = txt[1];
String ISBN = txt[2];
String dueDate = txt[3];
String returnDate = txt[4];
BookRequest newBookRequest = new BookRequest(blCode, memberID, ISBN, dueDate, returnDate);
list.insertTail((T) newBookRequest);

}
flr.close();
blr.close();
} catch (Exception e) {
}
return list;
}

public void writeFile(String fileName, MyList<T> list) {


try {
FileWriter flw = new FileWriter(fileName);
BufferedWriter blw = new BufferedWriter(flw);
for (Node<T> p = head; p != null; p = p.getNext()) {
blw.write(String.valueOf(p.getInfo())); //Vì kiểu dữ liệu của p là đối tượng Node
blw.newLine(); //Sử dụng hàm String.valueOf để chuyển p từ kiểu dữ liệu
} //đối tượng sang kiểu dữ liệu chuỗi
blw.close();
flw.close();
} catch (Exception e) {
}
}

/*Thể hiện dữ liệu theo danh sách riêng*/


public void showList() {
for (var p = head; p != null; p = p.getNext()) {
System.out.println(p.getInfo().toString());
}
}

/*Kiểm tra xem file rỗng hay không*/


public boolean isFileEmty(String fileName) {
try {
FileReader flr = new FileReader(fileName);
BufferedReader blr = new BufferedReader(flr);
String line = blr.readLine(); //Read data from file
if (line.equals("")) {
return true;
} //Null = false / Data = true
blr.close();
flr.close();
} catch (Exception e) {

return false;
}

public void borrowBook(MyList<T> list, MyList<Book> bookList, String ISBN) {


System.out.print("Input your ID: "); //Nhập thông tin để mượn sách
String memberId = sc.next();
/*Hàm lấy ngày cộng ngày*/
//Chỉnh format ngày tính theo ngày hiện tại
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
Calendar c1 = Calendar.getInstance(); //Hàm lấy ngày hiện tại
String dueDate = dateFormat.format(c1.getTime());
c1.roll(Calendar.DATE, 7); //Cộng thêm 7 ngày vào ngày hiện tại
String returnDate = dateFormat.format(c1.getTime());
int i = 1;
String blCode = "";
for (Node<T> p = head; p != null; p = p.getNext()) { //Duyệt danh sách phiếu mượn
i++; //để tạo mã phiếu mượn sách theo thứ tự
}
blCode = "" + i;

BookRequest book = new BookRequest(blCode, memberId, ISBN, dueDate, returnDate);


System.out.println(book.toString());
list.insertTail((T) book); //Thêm phiếu vào danh sách phiếu mượn

//Sách sau khi cho mượn sẽ được xét là đã cho


Node<Book> node = bookList.search(ISBN);
node.getInfo().setStatus("Loaned");

}
}
8. Lớp Main (Main.java)

import java.util.Scanner;

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
/**
*
* @author ducbao
*/
public class Main {

/*Tạo menu cho quản lý thư viện*/


public static void librarianMenu() {
System.out.println("1/ Search book by id or title");

System.out.println("2/ Search member account by name or id");

System.out.println("3/ Search borrow book ticket by title or member id");


}

/*Tạo menu cho người dùng*/


public static void memberMenu() {
System.out.println("1/ Search book by id or title");

System.out.println("2/ Borrow book");


}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

String fileMember = "Member.txt";


String fileLibrarian = "Librarian.txt";
String fileBook = "Book.txt";
String fileBookRequest = "BookRequest.txt";

/*Tạo list cho từng đối tượng*/


MyList<Member> memberList = new MyList<>();
MyList<Librarian> librarianList = new MyList<>();
MyList<Book> bookList = new MyList<>();
MyList<BookRequest> bookRequestList = new MyList<>();

/*Đọc dữ liệu từ Member*/


if (!memberList.isFileEmty(fileMember)) {
memberList.clear();
memberList.readFileMember(fileMember, memberList);
} else {
System.out.println("Null");
}

/*Đọc dữ liệu từ Librarian*/


if (!librarianList.isFileEmty(fileLibrarian)) {
librarianList.clear();
librarianList.readFileLibrarian(fileLibrarian, librarianList);
} else {
System.out.println("Null");
}

/*Đọc dữ liệu từ Book*/


if (!bookList.isFileEmty(fileBook)) {
bookList.clear();
bookList.readFileBook(fileBook, bookList);
} else {
System.out.println("Null");
}

/*Đọc dữ liệu từ BookRequest*/


if (!bookRequestList.isFileEmty(fileBookRequest)) {
bookRequestList.clear();
bookRequestList.readFileBook(fileBookRequest, bookRequestList);
} else {
System.out.println("Null");
}

boolean flag = true;


boolean check = true; //(true: member, false: librarian)

/*Đăng nhập*/
System.out.println("Log in!");

/*Nhập sai cho nhập lại*/


while (flag) {
System.out.println("Input your ID"); // Cho nhập ID trước
String dataID = sc.nextLine(); // Kiểm tra tên trùng với ID
if (memberList.compare(dataID)) {
System.out.println("Input your Name");
String dataName = sc.nextLine();
if (memberList.compare(dataName)) {
flag = false;
check = true;
System.out.println("Member");
} else {
System.out.println("Your name or your id is wrong");
flag = true;
}
} else if (librarianList.compare(dataID)) {
System.out.println("Input your Name");
String dataName = sc.nextLine();
if (librarianList.compare(dataName)) {
flag = false;
check = false;
System.out.println("Librarian");
} else {
System.out.println("Your name or your id is wrong");
flag = true;
}
}
}

if (!check) {
librarianMenu();
System.out.print("Choose: ");
int choice = sc.nextInt();
switch (choice) {
//Librarian search book for title or id
case 1 -> {
System.out.println("Input book's title or id ");
String data = sc.next();
var result = bookList.search(data).getInfo();
if (result != null) {
System.out.println(result);
} else {
System.out.println("Couldn't find or be borrowed");
}
}

case 2 -> {
System.out.println("Input member's name or id ");
String data = sc.next();
var result = memberList.search(data).getInfo();
if (result != null) {
System.out.println(result);
} else {
System.out.println("Couldn't find");
}
}

case 3 -> {
System.out.println("Input member's id");
String data = sc.next();
bookRequestList.searchMember(data);
}

default ->
throw new AssertionError();
}
} else if (check) {
boolean checkAns = true;
while (checkAns) {
memberMenu();
System.out.print("Choose: ");
int choice = sc.nextInt();
switch (choice) {
case 1 -> {
System.out.println("Input book's title or id ");
String data = sc.next();
var result = bookList.search(data).getInfo();
if (result != null) {
System.out.println(result);
} else {
System.out.println("Couldn't find or be borrowed");
}
System.out.println("Want to borrow book or find more book ?");
System.out.println("1/ Yes");
System.out.println("2/ No");
int ans = sc.nextInt();
switch (ans) {
case 1 ->
checkAns = true;

case 2 ->
checkAns = false;

default ->
throw new AssertionError();
}
}
case 2 -> {
boolean checkBook = false;
String ISBNchecked = "";
while (!checkBook) {
System.out.print("Input the ISBN: ");
String ISBN = sc.next();
if (bookRequestList.compare(ISBN)) {
Node<Book> node = bookList.search(ISBN);
node.getInfo().setStatus("Loaned");
checkBook = false;
System.out.println("Book loaned");
} else {
checkBook = true;
ISBNchecked = ISBN;
}
}
bookRequestList.borrowBook(bookRequestList, bookList, ISBNchecked);

bookList.showList();
System.out.println("Want to borrow book or find more book ?");
System.out.println("1/ Yes");
System.out.println("2/ No");
int ans = sc.nextInt();
switch (ans) {
case 1 ->
checkAns = true;

case 2 ->
checkAns = false;
}
}

default ->
throw new AssertionError();
}
}
}

memberList.writeFile(fileMember, memberList);
librarianList.writeFile(fileLibrarian, librarianList);
bookList.writeFile(fileBook, bookList);
bookRequestList.writeFile(fileBookRequest, bookRequestList);

}
}

You might also like