package Exam;

class Book {
    private String title;
    private String isbn;

    public Book(String title, String isbn) {
        this.title = title;
        this.isbn = isbn;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof Book)) return false;
        Book other = (Book) obj;
        return this.isbn.equals(other.isbn);
    }

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

    @Override
    public String toString() {
        return "제목: " + title + ", ISBN: " + isbn;
    }
}

public class C8_Pro01_Main {
    public static void main(String[] args) {
        Book b1 = new Book("자바 마스터", "9788994492032");
        Book b2 = new Book("자바 마스터", "9788994492032");

        System.out.println(b1);
        if (b1.equals(b2))
            System.out.println("두 객체는 같은 책입니다.");
        else
            System.out.println("다른 책입니다.");

        if (b1.hashCode() == b2.hashCode())
            System.out.println("hashCode 비교: 같음");
        else
            System.out.println("hashCode 비교: 다름");
    }
}
