Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

example attached Problem 2: Books (4 points) Download the program BookTester.java Write a class Book that provides each method needed by BookTester.java to compile and

example attached image text in transcribed
image text in transcribed
Problem 2: Books (4 points) Download the program BookTester.java Write a class Book that provides each method needed by BookTester.java to compile and run without error, producing the following output: Command Promo C:\java>javac Book.java C:\java>javac BookTester.java C:\java> java BookTester booki is: Great Expectations by Charles Dickens) book2 is: Great Expectations (by Charles Dickens) book3 is: To Kill a Mockingbird (by Harper Lee) booki.equals(book 2): true bookl - book 2: false book2.equals(book 3): false C:\javas The following UML diagram should be adhered to for full credit. For the equals method, it should be tested that both the titles and the authors are equals. The toString method builds the String needed to give the example output. Book Tester Book title : String author: String + main(String[] args) void setile(String new rule) void .setAuthor(String newAuthor) vold .getTitle String getAuthor: String .equals(Book thatBook): boolean toString : String //CS-151 //Homework 3 Problem 2 //This is the client program for the Book class //to be written in this homework problem. //A successful version of Book class will allow //BookTester to run without errors and provide the 1/output as listed in the homework. public class BookTester{ public static void main(String[args) { //create three books Book book1 = new Book(); book1.setTitle("Great Expectations"); book1.setAuthor("Charles Dickens"); Book book 2 = new Book(); book2.setTitle("Great Expectations"); book2.setAuthor( "Charles Dickens"); Book book 3 = new Book(); book3.setTitle("To Kill a Mockingbird"); book3.setAuthor( "Harper Lee"); //display the books System.out.println("bookl is: " + bookl); System.out.println("book2 is: + book 2); System.out.println("book3 is: " + book3); //test if books are equal System.out.println("bookl.equals(book 2): + booki.equals(book)); System.out.println("book1 == book2: + (bookl == book2) System.out.println("book2.equals(book3): + book2.equals(book3)); }//main }//class BookTester

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Not sure? Ask them.

Answered: 1 week ago