Java Question - Using the bottom code, create another class named "DigitalBook" as a subclass of the given "Book" class. Then, Make sure that the "DigitalBook" class contains two constructors: (1) one...


Java Question - Using the bottom code, create another class named "DigitalBook" as a subclass of the given "Book" class. Then, Make sure that the "DigitalBook" class contains two constructors: (1) one is the default constructor that takes no parameter, and (2) the other is a parameterized constructor that take 6 parameters. Be sure to use the “super” keyword in the constructors of the "DigitalBook" class. In the “main()” method of the “EX12_1” class, create four instances: “b1”, “b2”, d1”, and “d2”. Let “b1” and “b2” be the instances of the “Book” class, and let the “d1” and “d2” be the instance of the “DigitalBook” class. Be sure to use the specified constructor (as shown in attached picture) to initialize these instances. The Final Output is shown in the attached pictures.


Add the following code to the "class Book" code (Below the ___ line).


public class EX12_1
{
public static void main(String[] args)
{
/////add your code here
}
}


________________________________________________________________________________


class Book
{
public int totalPage, totalChapter;
public double unitPrice;
public String title, author, ISBN;
public String format = "Paper";
public Book() { }
public Book(String tl, String at, String isbn, int tp, int tc, double up)
{
title = tl;
author = at;
ISBN = isbn;
totalPage = tp;
totalChapter = tc;
unitPrice = up;
}
void showBook()
{
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("ISBN: " + ISBN);
System.out.println("Total Pages: " + totalPage);
System.out.println("Total Chapters: " + totalChapter);
System.out.println("Unit Price: " + unitPrice);
System.out.println("Format: " + format + "\n");
}


}



7. Finally, use the “showBook()

Extracted text: 7. Finally, use the “showBook()" method to display the details of the four books. Make sure the output looks similar to the following. Title: Jane Eyre Author: Charlotte Bronte ISBN: 9-871357-641 Total Pages: 150 Total Chapters: 10 Unit Price: 12.75 Format: Paper Title: Alice in Wonderland Author: Lewis Carroll ISBN: 9-871245-237 Total Pages: 124 Total Chapters: 14 Unit Price: 24.95 Format: Paper Title: Little Women Author: Louisa Alcott ISBN: 9-2436124-775 Total Pages: 120 Total Chapters: 9 Unit Price: 10.75 Format: PDF Title: CIS226 Author: Cypress College ISBN: 9-842654-291 Total Pages: 581 Total Chapters: 14 Unit Price: 5.15 Format: PDF
Instance<br>constructor<br>Values<br>b1<br>Default constructor of

Extracted text: Instance constructor Values b1 Default constructor of "Book" class Title: "Alice in Wonderland" Author: "Lewis Carroll" ISBN: "9-871245-237" Total Page: 124 Total Chapter: 14 Unit Price: 24.95 Title: "Jane Eyre" Author: "Charlotte Bronte" b2 Parameterized constructor of the "Book" class ISBN: "9-871357-641" Total Page: 150 Total Chapter: 10 Unit Price: 12.75 dl Default constructor of "DigitalBook" class Title: "Little Women" Author: "Louisa Alcott" ISBN: "9-2436124-775" Total Page: 120 Total Chapter: 9 Unit Price: 10.75 • Title: "CIS226" • Author: "Cypress College" ISBN: "9-842654-291" Total Page: 581 Total Chapter: 15 Parameterized constructor of the “DigitalBook" class d2 Unit Price: 5.15

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here