Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BookAssignment {
  4.     Scanner scan = new Scanner(System.in);
  5.     private String title;
  6.     private String author;
  7.     private int yearPublished;
  8.    
  9.     public BookAssignment(String bookTitle, String bookAuthor, int yearReleased) {
  10.         title = bookTitle;
  11.         author = bookAuthor;
  12.         yearPublished = yearReleased;
  13.     }
  14.    
  15.     public String getTitle() {
  16.         return title;
  17.     }
  18.    
  19.     public String getAuthor() {
  20.         return author;
  21.     }
  22.    
  23.     public int getYearPublished() {
  24.         return yearPublished;
  25.     }
  26.    
  27.     public String setTitle(String newTitle) {
  28.         title = newTitle;
  29.         return title;
  30.     }
  31.    
  32.     public String setAuthor(String newAuthor) {
  33.         author = newAuthor;
  34.         return author;
  35.     }
  36.    
  37.     public int setYear(int newYear) {
  38.         if (yearPublished <= 1000) {
  39.             yearPublished = newYear;
  40.         } else {
  41.             System.out.println("There are no matches.");
  42.         }
  43.         return yearPublished;
  44.     }
  45.    
  46.     public String toString() {
  47.         String s = "Title: " + title + "\nAuthor: " + author + "\nYear Published: " + yearPublished;
  48.         return s;
  49.     }
  50.    
  51.     public void oldOrNot(String bookName,String authorName,int yearPublished) {
  52.         if (yearPublished > 1990) {
  53.             System.out.println("This book was published during the digital age of books.");
  54.         } else {
  55.             System.out.println("This book was published before the digital age of books.");
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement