Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help( Extends java.lang.Object instead of ArrayList DataSetBook) Can you please help me the JAVA program? DataSetBook.java must have NO instance variables; it should use

Please help(Extends java.lang.Object instead of ArrayList DataSetBook) Can you please help me the JAVA program? DataSetBook.java must have NO instance variables; it should use inheritance instead. DataSetBook class should be as small as possible, but still meet the class specification. Please use DataSetBook extends java.lang.Object. Just need methods minBook, maxBook and toString. The code should something like public Book minBook(){ if (super.size() == 0{return null;} //so on Also please write a Tester.java for the program. --------------here is Book.java code, please don't change anything from here------------------- public class Book { private String author; private String title; private int pages; public Book(String auth, String titl, int pag) { author = auth; title = titl; pages = pag; } public int getPages() { return pages; } @Override public String toString() { return "Book [author=" + author + ", title=" + title + ", pages=" + pages + "] "; } // this is a really poor way to compare Book objects, but it will work for us /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Book other = (Book) obj; if (author == null) { if (other.author != null) return false; } else if (!author.equals(other.author)) return false; if (pages != other.pages) return false; if (title == null) { if (other.title != null) return false; } else if (!title.equals(other.title)) return false; return true; } } ------------------------------------------------------------------------------------------------------------------------------ Public class DataSetBook extends java.lang.Object Constructor Detail DataSetBook.java public DataSetBook() Default constructor Method Detail add public void add(Book objToAdd) Add a Book to the store Parameters: objToAdd - Book to add size public int size() The number of Books currently in the store Returns: number of Book objects getMin public Book getMin() Determine the Book with the fewest pages Returns: null if the store is empty. The book with the fewest pages otherwise. If more than one book has the fewest number of pages, the first one is returned. getMax public Book getMax() Determine the Book with the most pages Returns: null if the store is empty. The book with the most pages otherwise. If more than one book has the most number of pages, the first one is returned. toString public java.lang.String toString() A String representation of the store. Overrides: toString in class java.lang.Object Returns: A String containing the number of books in the store, the minimum book, the largest book, and the contents of the entire store.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

8 What personal development is elearning good at providing?

Answered: 1 week ago