By GokiSoft.com| 07:00 08/02/2020|
Java Basic

Java basic- Assignment - Quản lý sách

Xây dựng menu chương trình như sau.

Menu :

1. Nhập thông tin sách

2. Hiển thị tất cả sách ra màn hình

3. Nhập thông tin tác giả

4. Tìm kiếm tất cả sách được viết bởi tác giả

5. Thoát

Choose : ???

Yêu cầu :

Thiết kế lớp đối tượng tác giả gồm các thuộc tính sau (Tên, tuổi, bút danh, ngày sinh, quê quán) 

- Chú ý : cài đặt tất cả các thuộc tính chỉ có thuộc tính đọc dữ liệu

- Tạo các hàm tạo ko đối và đầy đủ đối số

- Tạo phương thức nhập thông tin tác giả, và xem thông tin tác giả

- Chú ý : Mỗi tác giả có bút danh duy nhất, ko được phép nhập trùng lặp tên bút danh của tác giả

Thiết kế lớp book gồm các thuộc tín : Tên sách, ngày xuất bản, but danh

- Cài đặt get/set cho các thuộc tính, hàm tạo ko đối và đầy đủ tham số

- Tạo hàm nhập và xem thông tin sách

- Chú ý : Khi nhập tên bút danh của tác giả, nếu chưa tồn tại thì -> Xuất hiện màn hình nhập thông tin cho tác giả đó luôn.

Xây dựng từng chức năng chương trình

Khi người dùng chọn 1 : Hỏi người dùng nhập số sách cần thêm -> sau đó nhập thông tin cho từng quấn sách -> và lưa vào 1 list.

Khi người dùng chọn 2 : In tất cả thông tin quấn sách.

Khi người dùng chon 3 : Hỏi người dùng nhập số tác giả -> Nhập thông tin tác giả.

Khi người dùng chọn 4 : Hiển thị màn hình nhập bút danh cần tìm -> in ra quấn sach của tác giả đó

Khi người dùng chọn 5 : Thoát chương trình.

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

thienphu [T1907A]
thienphu

2020-03-13 15:13:27



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package QuanlisachAss;

import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class Book {

    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package QuanlisachAss;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class Author {

    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package QuanlisachAss;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Thien Phu
 */
public class Main {

    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



Đường Thanh Bình [T1907A]
Đường Thanh Bình

2020-03-13 14:58:42



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {
    public static void main(String[] args) {
        List<Author> listAuthor = new ArrayList<>();
        List<Book> listBook = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int choose;

        do {
            showmenu();
            choose = Integer.parseInt(sc.nextLine());
            switch (choose) {
                case 1:
                    boolean check = false;
                    System.out.println("Nhap thong tin sach");
                    Book bk = new Book();
                    bk.input();
                    for (int i = 0; i < listAuthor.size(); i++) {
                        if (bk.getNickname().equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                            check = true;
                            break;
                        }
                    }
                    if (check) {
                        listBook.add(bk);
                    } else {
                        Author author = new Author(bk.getNickname());
                        author.input();
                        listAuthor.add(author);
                        listBook.add(bk);

                    }
                case 2:
                    for (Book listBook1 : listBook) {
                        listBook1.display();
                    }
                    break;
                case 3:
                    Author author = new Author();
                    author.input(listAuthor);
                    listAuthor.add(author);
                    for (Author author1 : listAuthor) {
                        author1.display();
                    }
                case 4:
                    String butdanh = sc.nextLine();
                    for (int i = 0; i < listBook.size(); i++) {
                        if (butdanh.equalsIgnoreCase(listBook.get(i).getNickname())) {
                            listBook.get(i).display();
                        }
                    }
                    break;
                case 5:
                    System.out.println("Exit thanh cong");
                    break;
                default:
                    System.out.println("Nhap sai roi");
                    break;
            }
        } while (choose != 5);
    }

    public static void showmenu() {
        System.out.println("1. Nhập thông tin sách");
        System.out.println("2. Hiển thị tất cả sách ra màn hình");
        System.out.println("3. Nhập thông tin tác giả");
        System.out.println("4. Tìm kiếm tất cả sách được viết bởi tác giả");
        System.out.println("5: Thoat");
        System.out.println("Choose: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;
import java.util.Scanner;
/**
 *
 * @author Administrator
 */
public class Book {
    String bookName;
    String createdAt;
    String nickname;

    public Book() {
    }

    public Book(String bookName, String createdAt, String nickname) {
        this.bookName = bookName;
        this.createdAt = createdAt;
        this.nickname = nickname;
    }

    public void input() {
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        bookName = input.nextLine();

        System.out.println("Ngay xuat ban: ");
        createdAt = input.nextLine();
        System.out.println("Nhap but danh");
        nickname = input.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getBookName() {
        return bookName;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public String getNickname() {
        return nickname;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", createdAt=" + createdAt + ", nickname=" + nickname + '}';
    }

}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assiment;

import java.util.List;
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Author {
    private String name;
    private int old;
    private String nickname;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String nickname) {
        this.nickname = nickname;
    }

    public Author(String name, int old, String nickname, String birthday, String address) {
        this.name = name;
        this.old = old;
        this.nickname = nickname;
        this.birthday = birthday;
        this.address = address;
    }

    public void input(List<Author> listAuthor) {
        Scanner sc = new Scanner(System.in);
        input();
        while (true) {
            System.out.println("Nhap butdanh tac gia");
            nickname = sc.nextLine();
            boolean a = true;
            for (int i = 0; i < listAuthor.size(); i++) {
                if (nickname.equalsIgnoreCase(listAuthor.get(i).getNickname())) {
                    a = false;
                }
            }
            if (a) {
                break;
            } else {
                System.err.println("nickname da ton tai");
            }
        }

    }

    public void input() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Nhap ten tac gia:");
        name = sc.nextLine();
        System.out.println("Nhap tuoi tac gia");
        old = Integer.parseInt(sc.nextLine());
        System.out.println("Nhap dia chi:");
        address = sc.nextLine();
    }

    public void display() {
        System.out.println(toString());
    }

    public String getName() {
        return name;
    }

    public int getOld() {
        return old;
    }

    public String getNickname() {
        return nickname;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", old=" + old + ", nickname=" + nickname + ", birthday=" + birthday + ", address=" + address + '}';
    }

}



hoangduyminh [T1907A]
hoangduyminh

2020-03-13 11:37:58



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Quanlysach;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Minh
 */
public class Main {
    public static void main(String[] args) {
        int choose,n;
        ArrayList<Author> authorList = new ArrayList<>();
        ArrayList<Book> bookList = new ArrayList<>();
        Scanner input = new Scanner(System.in);
        
        do{
          showMenu();
          choose = Integer.parseInt(input.nextLine());
          
          switch(choose){
              case 1: 
                  System.out.println("Nhap so sach can them");
                   n = Integer.parseInt(input.nextLine());
                  for (int i = 0; i < n; i++) {
                      Book book = new Book();
                      book.input();
                      boolean isFind = false;
                      for (int j = 0; j < authorList.size(); j++) {
                          if(authorList.get(j).getPseudonym().equalsIgnoreCase(book.getPseudonym())){
                            isFind = true;
                            break;
                          }
                      }
                      if(!isFind){
                        Author author = new Author(book.getPseudonym());
                        author.input();
                        
                        authorList.add(author);
                      }
                      bookList.add(book);
                  }
                  break;
              case 2:
                  for (Book book : bookList) {
                      book.display();
                  }
                  break;
                  
              case 3:
                  System.out.println(" Nhap so tac gia can them :");
                  n = Integer.parseInt(input.nextLine());
                  for (int i = 0; i < n; i++) {
                      Author author = new Author();
                      author.input(authorList);
                      authorList.add(author);
                  }
                          
                  break;
              case 4:
                  System.out.println("Nhap ten but danh can tim kiem :");
                  String pseudonym = input.nextLine();
                  
                  for (int i = 0; i < bookList.size(); i++) {
                      if(bookList.get(i).getPseudonym().equalsIgnoreCase(pseudonym)){
                      bookList.get(i).display();
                      }
                  }
                  break;
              case 5:
                  System.out.println("Exit");
                  break;
              default:
                  System.out.println("Erro!!");
                  break;
          }
        }while(choose!=5);
    }
    static void showMenu() {
        System.out.println("1. Nhap thong tin sach");
        System.out.println("2. Hien thi tat ca sach ra man hinh");
        System.out.println("3. Nhap thong tin tac gia");
        System.out.println("4. Tim kiem sach theo but danh");
        System.out.println("5. Thoat");
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Quanlysach;

import java.util.Scanner;

/**
 *
 * @author Minh
 */
public class Book {
    String bookName,pseudonym;
    int publicationdate;

    public Book() {
    }

    public Book(String bookName, String pseudonym, int publicationdate) {
        this.bookName = bookName;
        this.pseudonym = pseudonym;
        this.publicationdate = publicationdate;
    }

    public void input() {
        System.out.println("------------------------");
      Scanner input = new Scanner(System.in);
      
        System.out.println("Nhap vao ten sach:");
        bookName = input.nextLine();
        
        System.out.println("Nhap vao ngay san xuat:");
        publicationdate = Integer.parseInt(input.nextLine());
        
        System.out.println("Nhap vao but danh");
        pseudonym = input.nextLine();
    }
    
    public void display() {
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Book{" + "bookName=" + bookName + ", pseudonym=" + pseudonym + ", publicationdate=" + publicationdate + '}';
    }
    
    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getPseudonym() {
        return pseudonym;
    }

    public void setPseudonym(String pseudonym) {
        this.pseudonym = pseudonym;
    }

    public int getPublicationdate() {
        return publicationdate;
    }

    public void setPublicationdate(int publicationdate) {
        this.publicationdate = publicationdate;
    }
    
    
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Quanlysach;

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Minh
 */
public class Author {
     private String Name,address,pseudonym,Atbirth;
     private int age;

    public Author() {
    }

    public Author(String pseudonym) {
        this.pseudonym = pseudonym;
    }
    

    public Author(String Name, String address, String pseudonym, String Atbirth, int age) {
        this.Name = Name;
        this.address = address;
        this.pseudonym = pseudonym;
        this.Atbirth = Atbirth;
        this.age = age;
    }

  

    public void input(ArrayList<Author> authorList) {
        input();
     Scanner input = new Scanner(System.in);
        
        System.out.println("Nhap vao but danh:");
         while (true){
            pseudonym = input.nextLine();
            boolean isFind = false;
             for (int i = 0; i < authorList.size(); i++) {
                 if(authorList.get(i).getPseudonym().equalsIgnoreCase(pseudonym)){
                   isFind = true;
                   break;
                 }
             }
             if(!isFind){
                 break;
             }else{
                 System.err.println("Nhap but danh khac:");
             }
                 
         }
        
    }
    
    
     public void input() {
        System.out.println("-----------------------------");
      Scanner input = new Scanner(System.in);
      
        System.out.println("Nhap vao ten tac gia:");
        Name = input.nextLine();
        
        System.out.println("Nhap vao tuoi:");
        age = Integer.parseInt(input.nextLine());
        
        
        
        System.out.println("Nhap vao ngay sinh:");
        Atbirth = input.nextLine();
        
        System.out.println("Nhap vao dia chi");
        address = input.nextLine();
        
    }

    public String getName() {
        return Name;
    }

    public String getAddress() {
        return address;
    }

    public String getPseudonym() {
        return pseudonym;
    }

    public String getAtbirth() {
        return Atbirth;
    }

    public int getAge() {
        return age;
    }

   
    
    public void display() {
        System.out.println(toString());
    }

    
    
}



Trần Mạnh Dũng [T1907A]
Trần Mạnh Dũng

2020-03-13 10:26:04



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assignmentquan_li_sach;
import java.util.Scanner;
import java.util.ArrayList;
public class main {
    public static void main(String[] args) {
       int choose, n;
       
       ArrayList<Author> authorList = new ArrayList<>();
       ArrayList<Book> bookList = new ArrayList<>();
       
       Scanner input = new Scanner(System.in);
       do{
           ShowMenu();
           choose = Integer.parseInt(input.nextLine());
           
           switch(choose){
               case 1:
                   System.out.println("Nhap so sach can them: ");
                   n = Integer.parseInt(input.nextLine());
                   for (int i = 0; i < n; i++) {
                       Book book = new Book();
                       book.input();
                       boolean isFind = false;
                       for (int j = 0; j < authorList.size(); j++) {
                           if(authorList.get(j).getPseudonym().equalsIgnoreCase(book.getPseudonym())){
                               isFind = true;
                               break;
                           }
                       }if(!isFind){
                           Author author = new Author(book.getPseudonym());
                           author.input();
                           authorList.add(author);
                       }
                       bookList.add(book);
                   }
                   break;
               case 2:
                   for (Book book : bookList) {
                       book.display();
                   }
                   break;
               case 3:
                   System.out.println("Nhap so tac gia can them: ");
                   n = Integer.parseInt(input.nextLine());
                   
                   for (int i = 0; i < n; i++) {
                       Author author = new Author();
                       author.input(authorList);
                       authorList.add(author);
                   }
                   break;
               case 4:
                   System.out.println("Nhap ten but danh can tim: ");
                   String pseudonym = input.nextLine();
                   
                   for (int i = 0; i < bookList.size(); i++) {
                       if(bookList.get(i).getPseudonym().equalsIgnoreCase(pseudonym)){
                           bookList.get(i).display();
                       }
                   }
                   break;
               case 5:
                   System.out.println("BaiBaiiii!");
                   break;
               default:
                   System.err.println("Error...");
                   break;
           }
       }while(choose != 5);
    }
    
    static void ShowMenu() {
        System.out.println("1. Nhap thong tin sach");
        System.out.println("2. Hien thi tat ca sach ra man hinh");
        System.out.println("3. Nhap thong tin tac gia");
        System.out.println("4. Tim kiem sach theo but danh");
        System.out.println("5. Thoat");
        System.out.print("Nhap: ");
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assignmentquan_li_sach;
import java.util.Scanner;
public class Book {
    String BookName;
    String PublicationDate;
    String Pseudonym;

    public Book() {
    }

    public Book(String BookName, String PublicationDate, String pseudonym) {
        this.BookName = BookName;
        this.PublicationDate = PublicationDate;
        this.Pseudonym = pseudonym;
    }

    public String getBookName() {
        return BookName;
    }

    public void setBookName(String BookName) {
        this.BookName = BookName;
    }

    public String getPublicationDate() {
        return PublicationDate;
    }

    public void setPublicationDate(String PublicationDate) {
        this.PublicationDate = PublicationDate;
    }

    public String getPseudonym() {
        return Pseudonym;
    }

    public void setPseudonym(String pseudonym) {
        this.Pseudonym = pseudonym;
    }
    
    public void input() {
        System.out.println("=============================");
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten sach: ");
        BookName = input.nextLine();
        
        System.out.println("Ngay xuat ban: ");
        PublicationDate = input.nextLine();
        
        System.out.println("Nhap but danh: ");
        Pseudonym = input.nextLine();
    }
    
    public void display() {
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Book{" + "BookName=" + BookName + ", PublicationDate=" + PublicationDate + ", Pseudonym=" + Pseudonym + '}';
    }
}



/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assignmentquan_li_sach;
import java.util.ArrayList;
import java.util.Scanner;
public class Author {
    private String name;
    private int age;
    private String pseudonym;
    private String birthday;
    private String address;

    public Author() {
    }

    public Author(String pseudonym) {
        this.pseudonym = pseudonym;
    }

    public Author(String name, int age, String pseudonym, String birthday, String address) {
        this.name = name;
        this.age = age;
        this.pseudonym = pseudonym;
        this.birthday = birthday;
        this.address = address;
    }
    
    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public String getPseudonym() {
        return pseudonym;
    }

    public String getBirthday() {
        return birthday;
    }

    public String getAddress() {
        return address;
    }
    
    public void input(ArrayList<Author> authorList){
        
        input(); 
        Scanner input = new Scanner(System.in);
        
        System.out.println("Nhap but danh: ");
        while(true){
            pseudonym = input.nextLine();
            boolean isFind = false;
            for (int i = 0; i < authorList.size(); i++) {
                if(authorList.get(i).getPseudonym().equalsIgnoreCase(pseudonym)){
                    isFind = true;
                    break;
                }
            }
            if(!isFind){
                break;
            }else{
                System.err.println("Nhap but danh khac: ");
            }
        }
    }
    
    public void input(){
        System.out.println("=============================");
        Scanner input = new Scanner(System.in);
        System.out.println("Nhap ten tac gia: ");
        name = input.nextLine();
        
        System.out.println("Nhap tuoi: ");
        age = Integer.parseInt(input.nextLine());
        
        System.out.println("Nhap ngay sinh: ");
        birthday = input.nextLine();
        
        System.out.println("Nhap dia chi: ");
        address = input.nextLine();
    }
    
    public void display(){
        System.out.println(toString());
    }

    @Override
    public String toString() {
        return "Author{" + "name=" + name + ", age=" + age + ", pseudonym=" + pseudonym + ", birthday=" + birthday + ", address=" + address + '}';
    }
}