Guest User

Untitled

a guest
May 7th, 2012
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. class Book
  2. {
  3.     // The fields.
  4.     private String author;
  5.     private String title;
  6.     private int pages;
  7.     private String refNumber;
  8.  
  9.     /**
  10.      * Set the author and title fields when this object
  11.      * is constructed.
  12.      */
  13.     public Book(String bookAuthor, String bookTitle, int amountPages, String setRef)
  14.     {
  15.        
  16.         if(setRef == null)
  17.         {
  18.             refNumber = "";
  19.             author = bookAuthor;
  20.             title = bookTitle;
  21.             pages = amountPages;
  22.         }
  23.         if(setRef!= null)
  24.         {
  25.             refNumber = setRef;
  26.             author = bookAuthor;
  27.             title = bookTitle;
  28.             pages = amountPages;
  29.         }
  30.     }
  31.    
  32.     public String returnAuthor()
  33.     {
  34.         return author;
  35.     }
  36.    
  37.     public int getPages()
  38.     {
  39.         return pages;
  40.     }
  41.    
  42.     public String returnTitle()
  43.     {
  44.         return title;
  45.     }
  46.    
  47.     public void printAuthor()
  48.     {
  49.         System.out.println(author);
  50.     }
  51.    
  52.     public void printTitle()
  53.     {
  54.         System.out.println(title);
  55.     }
  56.    
  57.     public void printDetails()
  58.     {
  59.         System.out.println("Titel : " + title);
  60.         System.out.println("Auteur : " + author);
  61.         System.out.println("Aantal pagina's : " + pages);
Advertisement
Add Comment
Please, Sign In to add comment