Advertisement
LettuceCookie

Book Class Program Ver.2

Dec 15th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.85 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package finalprogrambook;
  7. import java.util.Scanner;
  8. /**
  9.  *
  10.  * @author
  11.  */
  12. public class FinalProgramBook
  13. {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args)
  19.     {
  20.        //These are the variables for this part of the program
  21.        //Parts of the book
  22.         String inputTitle = "";
  23.         String inputAuthor = "";
  24.         int inputPages = 0;
  25.         String inputPubName = "";
  26.         int inputBookYear = 0;
  27.        
  28.       //These are the objects for the Book class
  29.        Book bookObject = new Book(inputTitle, inputAuthor, inputPages,
  30.          inputPubName,inputBookYear);
  31.        
  32.        Book copiedBookObject = new Book(bookObject);
  33.        
  34.        
  35.      //This scanner takes user input
  36.      Scanner input = new Scanner(System.in);
  37.    
  38.      
  39.      
  40.      
  41.      //Ask the user for all information on the book
  42.      System.out.println(" Please enter in the following information. ");
  43.      
  44.      System.out.println(" \nEnter in the book's title: ");
  45.      inputTitle = input.nextLine();
  46.      
  47.      System.out.println(" \nEnter in the author's name: ");
  48.      inputAuthor = input.nextLine();
  49.      bookObject.setAuthor(inputAuthor);
  50.      
  51.      System.out.println(" \nEnter in the number of pages in the book: " );
  52.      inputPages = input.nextInt();
  53.      
  54.      System.out.println(" \nEnter in the publisher's name: ");
  55.      inputPubName = input.nextLine();
  56.      
  57.      System.out.println(" \nEnter in the year the book was published: ");
  58.      inputBookYear = input.nextInt();
  59.      
  60.  
  61.     //See if the book has the same number of pages as the asker book
  62.    System.out.println(" \nWe'll test to see if this book "
  63.             + "has the same number of pages as ours.");
  64.    
  65.    //both need to have values for pages be more than 0 !!!!!!!!!!!!!!!!!!!!
  66.    
  67.      if (copiedBookObject.hasSameNumPages(bookObject))
  68.         System.out.println("\nThey do share the same number of pages!");
  69.          
  70.      else
  71.         System.out.println("\nSorry, they have different amounts of pages.");
  72.    
  73.    
  74.      //NEED!!!????????
  75. ////Display the copy constructor //May not need
  76. //     System.out.println(" \nWe will now display the copy constructor. "
  77. //             + "\n" + copiedBookObject);
  78.    
  79.      
  80.  
  81.  //Display the information the user typed in
  82.      System.out.println(" \nNow we will display what you typed in. ");
  83.  
  84.  
  85.      System.out.println(" \nThe title of the book is " + bookObject.getTitle()
  86.      + "\n" + bookObject.toString()); //toString NEEDS CORRECTING ON CLASS FILE
  87.                                       //NEED SOME SORT OF RETURN VALUES IN FILE
  88.    
  89.            
  90.     }
  91.    
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement