Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Goal Write a class to represent a book, then write a driver program that demonstrates your class. Book class Your book class should contain

Programming Goal Write a class to represent a book, then write a driver program that demonstrates your class.

Book class Your book class should contain the following fields and methods.

Fields

title (String)

author (String)

isbn (String)

subject (String)

fiction (boolean)

editionNumber (int)

Methods

3 constructors

One constructor that has a parameter for each field

One constructor that has a parameter for the ISBN (all other fields should be initialized to 0, null or false)

One copy constructor that has a Book parameter

Accessor (getter) and mutator (setter) for each field

A toString method that displays each field on a line, along with a heading for each field. For example, if title = "Introduction to Computing Systems", then this method would print Title: Introduction to Computing Systems for the title field

A copy method that takes a Book parameter

2 equal methods

One that has a Book parameter and returns true if each attribute of each object is the same

One that has a String parameter for the ISBN and returns true if the ISBN stored in the String parameter is the same as the Book object's ISBN

Driver Program The driver program will demonstrate the use of the Book class.

Your program should begin by creating Book objects for the following 2 books (call one of the objects book1 and the other book2). Use constructor #1 to create one object and use constructor #2 to create the other object.

Title: Introduction to Computing Systems Author: Yale Patt ISBN: 9780087463 Subject: Computer Science Fiction?: No Edition: 2 Title: Crime and Punishment Author: Fyodor Dostoevsky ISBN: 9002322134 Subject: Literature Fiction?: Yes Edition: 1

Print each object's state.

For the object that was created with constructor #2, call the proper setter method on any field that is currently set to 0, null or false, and set it to its proper value. Print this object's new state.

Test to see if your objects are equal. Print the result of this test.

Create a new object, book3, to represent the following book. Use constructor #1.

Title: Essential Matlab for Engineers and Scientists Author: Brian Hahn ISBN: 9883740001 Subject: Engineering Fiction?: No Edition: 3

Create an object called book4 that is a copy of book3. Use the copy constructor to do this.

Test to see if book3 and book4 are equal. Print the result of this test.

Test to see if book2 is equal to the book with the ISBN: 9002322134. Print the result of this test.

For each work of fiction, print out the book's edition. For each work of non-fiction, print out the book's subject.

Specific Coding Requirements

Name your class file Book.java and name your driver BookDriver.java

Make all fields private and all methods public

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

Develop a marketing campaign for a training course or program.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago