Advertisement
GSculerlor

Exercise 2.86

Sep 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public class Book {
  2.  
  3.     private String author;
  4.     private String title;
  5.     private int pages;
  6.    
  7.     public Book(String bookAuthor, String bookTitle, int bookPages) {
  8.         author = bookAuthor;
  9.         title = bookTitle;
  10.         pages = bookPages;
  11.     }
  12.    
  13.     public String getAuthor() {
  14.         return author;
  15.     }
  16.     public String getTitle() {
  17.         return title;
  18.     }
  19.    
  20.     public int getPages() {
  21.         return pages;
  22.     }
  23.    
  24.     public void printAuthor() {
  25.         System.out.println(author);
  26.     }
  27.    
  28.     public void printTitle() {
  29.         System.out.println(title);
  30.     }
  31.    
  32.     public void printDetails() {
  33.         System.out.println("Title: " + title + ", Author: " + author + ", Pages: " + pages);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement