daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Oct 13th, 2017 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Read and try to write  the necessary lines of code to complete the following program:
  2.  
  3. public class Book {
  4.  
  5.  
  6.  
  7.     private String Name="Nutuk";//name of book
  8.  
  9.     private String author="M.K.Ataturk";//author of book
  10.  
  11.     private int npages=192;//number of pages
  12.  
  13.    
  14.  
  15.     //Constructor
  16.  
  17.     public Book(String Name,String Author,int npages){
  18.  
  19.         this.Name=Name;
  20.  
  21.         this.author=Author;
  22.  
  23.         this.npages=npages;
  24.  
  25.     }
  26.  
  27. //Write a constructor that assign just Name and Author of the book(not npages)
  28.  
  29.     public String getName() {
  30.  
  31.         return Name;
  32.  
  33.     }
  34.  
  35.     public void setName(String name) {
  36.  
  37.         Name = name;
  38.  
  39.     }
  40.  
  41. //Write a getter method for author name
  42.  
  43.  
  44.  
  45.     public void setAuthor(String author) {
  46.  
  47.         this.author = author;
  48.  
  49.     }
  50.  
  51.     public int getNpages() {
  52.  
  53.         return npages;
  54.  
  55.     }
  56.  
  57.     //write a setter method for number of pages
  58.  
  59.    
  60.  
  61.  
  62. }
RAW Paste Data
Top