Question

A java class named Book contains: instance data for the title, author, publisher and copyright year...

A java class named Book contains:

instance data for the title, author, publisher and copyright year

a constructor to accept and initialize the instance data variables

set and get methods

a toString() method to return a formatted, multi-line description of the book

Produce a child class that inherits from Book. The class is called Dictionary. Dictonary must include:

instance data that describes the number of words in the dictionary

a constructor that takes in all information needed to describe a dictionary

a toString that lists the title, author, publisher, copyright year, and number of words

set and get methods

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public void setbpublisher (String bpublisherName) bpublisherbpublisherName; public String getbpublisher () return bpublisher;OUTPUT ASTE SOURICE etaut ilberschat

import java.util.*;

//class name declared//

class Book

{

// Bookcontent declared in string//

    private String btitle;

    private String bauthor;

    private String bpublisher;

    private int CopyRightYear;

     //Decleration of the Bookcontents//

    public Book(String bookbtitle, String bauthorName, String bpublisherName,

    int date)

     //Array list of the categories in book//

     {

        btitle = bookbtitle;

        bauthor = bauthorName;

        bpublisher = bpublisherName;

        CopyRightYear = date;

    }

    public Book()

     {

          //btitle of the book//

        btitle = "Born to win";

        bauthor = "Abdhul kalam";

        bpublisher = "AVS";

        CopyRightYear = 2010;

    }

     //Set method//

    public void setbauthor(String bauthorName)

          {

              bauthor = bauthorName;

          }

     //Get method//

    public String getbauthor()

          {

              return bauthor;

          }

     public void setbtitle(String bookbtitle)

          {

              btitle = bookbtitle;

          }

     //btitle of the book//

    public String getbtitle()

          {

              return btitle;

          }

    public void setbpublisher(String bpublisherName)

          {

              bpublisher = bpublisherName;

          }

    public String getbpublisher()

          {

              return bpublisher;

          }

    public void setCopyRightYear(int year)

          {

              CopyRightYear = year;

          }

    public int getCopyRightYear()

          {

              return CopyRightYear;

          }

     //Require to explore the string//

    public String toString()

          {

              return (btitle + "\t" + bauthor + "\t" + bpublisher + "\t" + CopyRightYear);

          }

}

//Inheriting from class//

public class Dicitionary

     {

          //Main method//

          public static void main(String[] args)

              {

                   //integer decleration//

                   final int year2 = 1011;

                   final int year3 = 2029;

                   // creates the object for book//

                   Bookbname1 = new Book("DBMS\n", "Silberschatz\n", "cortez\n", year2);

                   Bookbname2 = new Book("OOPS\n", "Balakrishnan\n", "kraigh\n", year3);

                   //To display in the output window//

                   System.out.println(bname1);

                   System.out.println(bname2);

              }

     }

Add a comment
Know the answer?
Add Answer to:
A java class named Book contains: instance data for the title, author, publisher and copyright year...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher,...

    cs55(java) please. Write a class called Book that contains instance data for the title, author, publisher, price, and copyright date. Define the Book constructor to accept and initialize this data. Include setter and getter methods for all instance data. Include a toString method that returns a nicely formatted, multi-line description of the book. Write another class called Bookshelf, which has name and array of Book objects. Bookself capacity is maximum of five books. Includes method for Bookself that adds, removes,...

  • Write a class named Book containing: Two instance variables named title and author of type String....

    Write a class named Book containing: Two instance variables named title and author of type String. A constructor that accepts two String parameters. The value of the first is used to initialize the value of title and the value of the second is used to initialize author. A method named toString that accepts no parameters. toString returns a String consisting of the value of title, followed by a newline character, followed by the value of author.

  • 1- Create the base class Book that has the following instance variables, constructor, and methods title...

    1- Create the base class Book that has the following instance variables, constructor, and methods title ( String) isbn ( String) authors (String) publisher (String) edition ( int) published_year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method // that return sting representation of Book object. 2- Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title ( String) isbn...

  • C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (Strin...

    C# programming 50 pts Question 2:2 1- Create the base class Book that has the following instance variables, constructor, and methods title (String) isbn (String) authors (String) publisher (String) edition ( int) published year (int) Constructor that takes all of the above variables as input parameters. set/get methods ToString method// that return sting representation of Book object. 2-Create the sub class New_Book that is derived from the base class Book and has the following instance variables, constructor, and methods: title...

  • Create a class named Book that contains data fields for the title and number of pages....

    Create a class named Book that contains data fields for the title and number of pages. Include get and set methods for these fields. Next, create a subclass named Textbook, which contains an additional field that holds a grade level for the Textbook and additional methods to get and set the grade level field. Write an application that demonstrates using objects of each class. Save the files as Book.java, Textbook.java, and DemoBook.java.

  • Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double...

    Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....

  • Java Program: Design a class “Book” with the data attributes title - String, author - String,...

    Java Program: Design a class “Book” with the data attributes title - String, author - String, yearPublished - integer and price - double. Write a parameterized constructor that initializes the attributes. Write accessor and mutator methods, and a print method that prints all of the attributes. In the main method, create a single object and give it values of your choice. Call the print method to print the values. Sample Run: The Book is: The Art of Computer Programming Donald...

  • Write a class called Shelf that contains instance data that represents the length, breadth, and capacity...

    Write a class called Shelf that contains instance data that represents the length, breadth, and capacity of the shelf. Also include a boolean variable called occupied as instance data that represents whether the shelf is occupied or not. Define the Shelf constructor to accept and initialize the height, width, and capacity of the shelf. Each newly created Shelf is vacant (the constructor should initialize occupied to false). Include getter and setter methods for all instance data. Include a toString method...

  • Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide...

    Write a class called Book. Here are the relevant attributes: title author yearPublished            bookPriceInCAD Provide a constructor that takes parameters to initialize all the instance variables. The constructor calls the mutator (set) methods to initialize the instance variables. Provide an accessor (get) and mutator (set) for each instance variable. The mutators all validate their parameters appropriately and use them only if valid. If the passed parameter was invalid an IllegalArgumentException will be thrown with a proper error message A...

  • Design and implement a Java data structure class named BookShelf which has an array to store...

    Design and implement a Java data structure class named BookShelf which has an array to store books and the size data member. The class should have suitable constructors, get/set methods, and the toString method, as well as methods for people to add a book, remove a book, and search for a book. Design and implement a Java class named Book with two data members: title and price. Test the two classes by creating a bookshelf object and five book objects....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT