Question: DatSetGeneric.java Please help me the java program? Here is the requirement: Here is the code from the instructor for the program. ---------- Book.java ---------- public

DatSetGeneric.java

Please help me the java program? Here is the requirement:

DatSetGeneric.java Please help me the java program? Here is the requirement: Here

Here is the code from the instructor for the program.

----------Book.java----------

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; } } 

-------DataSetBook.java---------

import java.util.ArrayList; /**  * A simple store for Book objects.  *  * @author student  *  */ public class DataSetBook { private ArrayList data; /**  * Default constructor  */  public DataSetBook() { data = new ArrayList(); } /**  * Add a Book to the store  *  * @param objToAdd Book to add  */  public void add(Book objToAdd) { data.add(objToAdd); } /**  * The number of Books currently in the store  *  * @return number of Book objects  */  public int size() { return data.size(); } /**  * Determine the Book with the fewest pages  *  * @return 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.  */  public Book getMin() { if (data.isEmpty()) { return null; } Book mEle = data.get(0); for (int i = 1; i  (data.get(i).getPages())) { mEle = data.get(i); } } return mEle; } /**  * Determine the Book with the most pages  *  * @return 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.  */  public Book getMax() { if (data.isEmpty()) { return null; } Book mEle = data.get(0); for (int i = 1; i /**  * A String representation of the store.  *  * @return A String containing the number of books in the store,  * the minimum book, the largest book, and  * the contents of the entire store.  */  @Override public String toString() { return "DataSetBook [ size()=" + size() + " getMin()=" + getMin() + " getMax()=" + getMax() + " Books= " + data.toString() + "]"; } } 

----------Measurable.java---------

public interface Measurable { int getMeasure(); } 

Generics give the application writer compile-time help in keeping boats and buildings out of his book store. A Book and DataSetBook classes and a Measurable interface are provided, but feel free to rewrite them if that seems easier. You may also wish to start from a different version of Dataset; that's up to you. You are to write a generic class DataSetGeneric. DataSetGeneric should provide the usual add, size, getMin, getMax and toString methods. This should be a generic class so that only elements of the specified type are allowed into the data store. All of its elements should implement the Measurable interface, however, that's what you will rely on to implement getMin and getMax Also provide a tester for DataSetGeneric. Generics give the application writer compile-time help in keeping boats and buildings out of his book store. A Book and DataSetBook classes and a Measurable interface are provided, but feel free to rewrite them if that seems easier. You may also wish to start from a different version of Dataset; that's up to you. You are to write a generic class DataSetGeneric. DataSetGeneric should provide the usual add, size, getMin, getMax and toString methods. This should be a generic class so that only elements of the specified type are allowed into the data store. All of its elements should implement the Measurable interface, however, that's what you will rely on to implement getMin and getMax Also provide a tester for DataSetGeneric

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!