Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BookAssignment {
- Scanner scan = new Scanner(System.in);
- private String title;
- private String author;
- private int yearPublished;
- public BookAssignment(String bookTitle, String bookAuthor, int yearReleased) {
- title = bookTitle;
- author = bookAuthor;
- yearPublished = yearReleased;
- }
- public String getTitle() {
- return title;
- }
- public String getAuthor() {
- return author;
- }
- public int getYearPublished() {
- return yearPublished;
- }
- public String setTitle(String newTitle) {
- title = newTitle;
- return title;
- }
- public String setAuthor(String newAuthor) {
- author = newAuthor;
- return author;
- }
- public int setYear(int newYear) {
- if (yearPublished <= 1000) {
- yearPublished = newYear;
- } else {
- System.out.println("There are no matches.");
- }
- return yearPublished;
- }
- public String toString() {
- String s = "Title: " + title + "\nAuthor: " + author + "\nYear Published: " + yearPublished;
- return s;
- }
- public void oldOrNot(String bookName,String authorName,int yearPublished) {
- if (yearPublished > 1990) {
- System.out.println("This book was published during the digital age of books.");
- } else {
- System.out.println("This book was published before the digital age of books.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement