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.

  • 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....

  • 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...

  • 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....

  • Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance...

    Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...

  • Write a definition for a class named Book with attributes title, price and author, where author...

    Write a definition for a class named Book with attributes title, price and author, where author is a Contact object and title is a String, and price is a float number. You also need to define the Contact class, which has attributes name and email, where name and email are both String. Instantiate a couple of Book objects that represents books with title, price and author (You can come up with the attributes values for each object) Write a function...

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
ADVERTISEMENT