티스토리 뷰

JAVA

도서관 사서

코린이도이 2023. 9. 24. 17:49

1. Book의 인스턴스 b1, b2를 각각 생성하고 위 표의 있는 값을 Book의 매개 변수에 넣은 후 printInfo 메소드를 활용하여 출력하세요.

변수명 isbn author title publisher
b1 978-89-123456-0-1 William Shakespeare Hamlet Good Books
b2 978-89-234567-0-9 Miguel de Cervantes Don Quixote Literature World
class Book {
	String isbn;
    String author;
    String title;
    String publisher;
    
    void printInfo(){
    	System.out.println("ISBN : " + isbn + "\nauthor : " + author + "\ntitle : " + title + "\npublisher : " + publisher + "\n");
    }
    Book(String isbn, String author, String title, String publisher) {
    	this.isbn = isbn;
        this.author = author;
        this.title = title;
        this.publisher = publisher;
    }
}

public class Main {
	public static void main(String args[]) {
    	Book b1 = new Book("978-89-123456-0-1", "William Shakespeare","Hamlet", "Good Books");
        b1.printInfo();
        Book b2 = new Book("978-89-234567-0-9","Miguel de Cervantes", "Don Quixote", "Literature World");
        b2.printInfo();
    }
}

'JAVA' 카테고리의 다른 글

웹사이트 여러가지 태그  (0) 2023.10.04
웹사이트 제작(HTML)  (0) 2023.10.03
붕어빵  (0) 2023.09.24
항공기 운행  (0) 2023.09.24
좌석 번호  (0) 2023.09.24
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함