Task: Create 2 Java classes Book BookDemo → contains the main() method Instructions: First create a class called Book The class Book DOES NOT HAVE a main method Create instance variables for: title: a String that contains the title of the book. author: a String that contains the name of the author publisher: a String that contains the name of the publishing house numCopiesSold: an int that holds the number of book copies sold. This must be a nonnegative value. yearOfRelease: an int that contains the year of the book's release. Only consider books released during 1950 – 2020. Create the Default Constructor – sets everything to default values and has no parameters. Create a Parameterized Constructor – with 5 parameters Create Accessors and Mutators for each instance variable MAKE SURE THE MUTATORS CHECK FOR VALID VALUES! Create the following Methods toString(): returns a String that contains the values of all instance variables for a particular Book object. equals(): takes in another instance of a Book and returns true only if the both book objects contain the same values for all instance variables. Finally create a class called BookDemo This class DOES HAVE a main method Create at least 3 different types of books Test if the accessors, mutators, and other methods work as intended.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

In java preferably eclipse

Task: Create 2 Java classes

Book

BookDemo → contains the main() method

Instructions: First create a class called Book

The class Book DOES NOT HAVE a main method

Create instance variables for:

title: a String that contains the title of the book.

author: a String that contains the name of the author

publisher: a String that contains the name of the publishing house

numCopiesSold: an int that holds the number of book copies sold. This must be a nonnegative value.

yearOfRelease: an int that contains the year of the book's release. Only consider books released during 1950 – 2020.

Create the Default Constructor – sets everything to default values and has no parameters.

Create a Parameterized Constructor – with 5 parameters

Create Accessors and Mutators for each instance variable

MAKE SURE THE MUTATORS CHECK FOR VALID VALUES!

Create the following Methods

toString(): returns a String that contains the values of all instance variables for a particular Book object.

equals(): takes in another instance of a Book and returns true only if the both book objects contain the same values for all instance variables.

Finally create a class called BookDemo

This class DOES HAVE a main method

Create at least 3 different types of books

Test if the accessors, mutators, and other methods work as intended.

Sample Output:

Creating the first book object!

Printing the default values of the first book object:

Book Title: title unknown

Author: unknown

Number of Copies Sold: 0

Year of Release: 2020

Enter the title of the first book: Harry Potter and the Sorcerer's Stone

Enter the author of the first book: J K Rowling

Enter the number of copies sold: 500000000

Enter the year of release of the first book: 1997

The updated values of the first book are:

Book Title: Harry Potter and the Sorcerer's Stone

Author: J K Rowling

Number of Copies Sold: 500000000

Year of Release: 1997

Enter the title of the second book: Harry Potter and the Deathly Hallows

Enter the author of the second book: J K Rowling

Enter the number of copies sold: 8300000

Enter the year of release of the second book: 2007

Creating the second book object...

The details of the second book are:

Book Title: Harry Potter and the Deathly Hallows

Author: J K Rowling

Number of Copies Sold: 8300000

Year of Release: 2007

The first book is different from the second book!

Goodbye!

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage