Question

Create classes to implement the following inheritance hierarchy: Book TextBook E-Book All books have a title,...

Create classes to implement the following inheritance hierarchy:
Book
TextBook E-Book

All books have a title, an ISBN number, a cost and a size (i.e., number of pages). Textbooks
also have an area designation (such as ComputerScience or Anthropology) and a student
discount percentage. E-books contain a platform designation (such as Kindle or Nook). You
need only list the elds and a constructor for each class.

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

// Book class

public abstract class Book {

private String title;

private int ISBN;

private double cost;

private int size;

public String getTitle() {

return title;

}

public void setTitle(String title) {

this.title = title;

}

public int getISBN() {

return ISBN;

}

public void setISBN(int iSBN) {

ISBN = iSBN;

}

public double getCost() {

return cost;

}

public void setCost(double cost) {

this.cost = cost;

}

public int getSize() {

return size;

}

public void setSize(int size) {

this.size = size;

}

public Book(){

this.cost = 0;

this.ISBN = 0;

this.size = 0;

this.title = " ";

}

public Book(double cost, int size, int isbn, String title) {

this.title = title;

this.cost = cost;

this.ISBN = isbn;

this.size = size;

}

}

//TextBook Class

public class TextBook extends Book{

private String Designation;

private double dispercent;

public double getDispercent() {

return dispercent;

}

public void setDispercent(double dispercent) {

this.dispercent = dispercent;

}

public TextBook() {

super();

this.Designation = "";

this.dispercent = 0;

}

public TextBook(double dis, String desig, double cost, int isbn, int size, String title) {

super(cost, size, isbn, title);

this.Designation = desig;

this.dispercent = dis;

}

public String getDesignation() {

return Designation;

}

public void setDesignation(String designation) {

Designation = designation;

}

}

//Ebook Class

public class Ebook extends Book {

private String platformDesig;

public Ebook() {

super();

this.platformDesig = "";

}

public Ebook(String plat, double cost, int size, int isbn, String title) {

super(cost, size, isbn, title);

this.platformDesig = plat;

}

public String getPlatformDesig() {

return platformDesig;

}

public void setPlatformDesig(String platformDesig) {

this.platformDesig = platformDesig;

}

}

Add a comment
Know the answer?
Add Answer to:
Create classes to implement the following inheritance hierarchy: Book TextBook E-Book All books have a title,...
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
  • C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Ever...

    C++ In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...

  • You need to program a simple book library system. There are three java classes Book.java   //...

    You need to program a simple book library system. There are three java classes Book.java   // book object class Library.java   //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...

  • Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use impl...

    Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...

  • C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header ...

    C++ project we need to create a class for Book and Warehouse using Book.h and Warehouse.h header files given. Then make a main program using Book and Warehouse to read data from book.dat and have functions to list and find book by isbn Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • Please provide original Answer, I can not turn in the same as my classmate. thanks In...

    Please provide original Answer, I can not turn in the same as my classmate. thanks In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a “next” pointer. Textbook Type Attribute String title String author String ISBN Textbook* next Textbook Type Attribute String title String...

  • Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The...

    Overview: You will be writing classes that implement a playlist simulation for a music streaming app.The Playlist class will contain a dynamic array of Song objects, and the Song class contains several pieces of information about a song. You will need to: 1) Finish the writing of two classes: Song and Playlist. The full header file for the Song class has been provided in a file called Song.h. 2) Write a main program (filename menu.cpp) that creates a single Playlist...

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