Question
Java: Implent the following 3 methods in the bookstore class: a method searching the library of Books for a given author and returning an ArrayList
Java: Implent the following 3 methods in the bookstore class:
a method searching the library of Books for a given author and returning an ArrayList of such Books.
a method returning an ArrayList of Books whose price is less than a given number.
a method returning the Book object with the lowest price in the library.
########################
import java.util.ArrayList;
public class BookStore { private ArrayList
###############################
import java.util.*;
public class BookSearchEngine { public static void main( String [] args ) { BookStore bookStore = new BookStore( ); System.out.println( " Our book collection is:" ); System.out.println( bookStore ); Scanner keyboard = new Scanner(System.in); System.out.println( " Searching titles, enter a keyword" ); String keyword = keyboard.next(); ArrayList
########################################
public class Book { private String title; private String author; private double price; /** default constructor */ public Book( ) { this.title = ""; this.author = ""; this.price = 0.0; } /** overloaded constructor * @param newTitle the value to assign to title * @param newAuthor the value to assign to author * @param newPrice the value to assign to price */ public Book( String newTitle, String newAuthor, double newPrice ) { this.title = newTitle; this.author = newAuthor; this.price = newPrice; } /** getTitle accessor method * @return the title */ public String getTitle( ) { return this.title; } /** getAuthor accessor method * @return the author */ public String getAuthor( ) { return this.author; } /** getPrice accessor method * @return the price */ public double getPrice( ) { return this.price; } /** toString * @return title, author, and price */ public String toString( ) { return ( "title: " + this.title + "\t" + "author: " + this.author + "\t" + "price: " + this.price ); } }
###################################
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