Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java net beans 4. Pick 2 methods below to add functionalities to the BookStore class. a. Find the most expensive book (if there are 2

java net beans
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
4. Pick 2 methods below to add functionalities to the BookStore class. a. Find the most expensive book (if there are 2 books have the same price, return one of them) public Book getMostExpensiveBook () b. Find the books by a price range (include low and high) public ArrayList getBooksForPriceRange(double low, double high) C. Add a list of new books to the store book list public void addBooks (ArrayList newBooks) d. Apply discount to all the books (holiday sales event) public void applyDiscountToAllBooks (double discount) I 5. Extra credit: Sort the booklist by price (low -> high) 6. Add code in BookStore Manager class to test your new methods. Feel free to change the data in book list to test different scenarios import java.util.ArrayList; public class BookStoreManager ! @param args the command line arguments public static void main(String[] args) { 1/ create a bookstore Bookstore mystore - new Bookstore(); w initialize books mystore.getBooklist().add(new Book "Intro to Java", "James", 56.99 ) ) :| mystore.getBooklist() .add(new Book( 'Advanced Java", "Green") 65.99 ) ): mystore.getBooklist() .add(new Book "Jaya Sertlets", "Brown", 75.99 ) ): mystore.getBooklist() .add(new Book ( "Into HTML", James". 29.49 ) ): mystore.getBooklist() .add(new Book ( "Intro to Flash", "James", 34.99 ) ); mystore.getBooklist().add( new Book ( "Advanced HTML", "Green", 56.99 ) ): mystore.getBooklist().trimToSize(): W printout the book mystore.printoutBooklist: W search for the boat with a ArrayList booklist; public BookStore () { booklist = new ArrayList 0); 3 public void printoutBookList() { System.out.println("----- My book store has ==--=-"); for (Book abook : booklist) { System.out.println(abook); System.out.println("- } public void printoutBooklist (ArrayList mylist) { System.out.println("My book list has ---- for (Book abook : mylist) { System.out.println(abook): > System.out.println(". 3 public ArrayList searchForTitle( String searchString ) { ArrayList(); Book aBook; for (int i =0; i getBooklist() { return booklist; > public void setBooklist (ArrayList booklist) { this.booklist booklist: 1 ) public class Book 1 private String title: private String author; private double price: public Book() > public Book (String myTitle, String myAuthor, double myprice) { title = myTitle: author = myAuthor: price - myprice; I public String toString() return getTitle() + " written by + getAuthor() + ", price is " + this.price: > 3 public double getPrice() return price? public void serPrice (double myPrice) price = myPrice: 1 public String getTitle() { return title: public String toString() [ return getTitle() + " written by " + getAuthor() + ", price is " + this.price; ) public double getPrice () { return price: ) public void serPrice (double myPrice) price - myPrice: 1 public String getTitle() { return title; I 1 public void setTitle(String title) this.title title: } public String getAuthor() { return author; public void setAuthor (String author) his.author = author: }

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

Students also viewed these Databases questions

Question

Compare and contrast high- and low-load environments

Answered: 1 week ago

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago

Question

3. What strategies might you use?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago