Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4 0 . 1 Create a Class LAB ACTIVITY 4 0 . 1 . 1 : Create a Class 8 / 1 0 For this
Create a Class
LAB ACTIVITY
: Create a Class
For this lab, you will write a class that represents a book. The Book class will support the following hidden state:
title as a Java String
authors as an ArrayList of String
ISBN as a Java String
number of pages as an integer
retail price as a double
publisher as a Java String
Your Book class must support the following interface:
public BookString title, String isbn, int np double rp String publisher, String authors
public String getTitle
public String getIsbn
public int getNumberOfPages
public double getRetailPrice
public String getAuthors
public String toString
For example, the Java statement statements:
Book b new BookJava How to Program",
"PrenticeHall",
"Harvey M Deitel", "Paul J Deitel" ;
System.out.printfsn b;
should produce the following output:
That is the toString should produce a string that has the book object state in this order
title
authors comma separated with space after the comma inside
number of pages
retail price
publisher
ISBn
inside
If the constructor receives a null value for any of the String state, that state should be set to "Unknown". If no authors are given, the ArrayList should contain a single string "Unknown".
For example, the Java statement:
Book b new Booknull null, null;
System.out.printfsn b;
should produce the output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started