Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This class represents a physical book in the bookstore (visible or invisible) and should implement an interface that will allow two Books to be
This class represents a physical book in the bookstore (visible or invisible) and should implement an interface that will allow two Books to be compared according to their natural ordering. Variables (private): title (String) edition (whole number) price (floating point number) Constructor(s): Two constructors are required. A constructor that takes in the title, edition, and price A constructor that takes in the title and price and has a default edition of 1 Be sure any constructors for this class have parameters in the same order as the variables listed above, because the BookInputDialog class will not compile otherwise. You must use proper constructor chaining and chain from the smallest number of parameters to the largest. Methods: Write setters and getters for all of the instance variables. These methods should be named getVariableName and setVariableName, but with VariableName replaced with the actual name of the instance variable. Books have a NATURAL ORDERING of: o title in ascending (alphabetical, case-insensitive) order, but if the titles are equal then. o edition in descending (greatest to least) order, but if the editions are equal then. o price in ascending (least to greatest) order O HINT - what interface have we discussed in this class that allows you to compare two objects according to their natural ordering? Write a tostring method that contains the instance variables for the Book. The String representation of the Book should be in the following format: Title: , Edition: , Price: o Be sure to print to exactly two decimal places for the price. Page < 3 > of 9 ZOOM Store Class Please be sure this class properly implements the StoreOrganizer interface because the BookStore GUI will not compile otherwise. This will be the class where the sorting and searching of the books are completed. Variables (protected): Book [] books: array to hold all of the books in the bookstore. Constructor(s): A single constructor that takes in an int parameter named numBooks and represents the max number of books that the book store can hold. This constructor should initialize the books variable with the numBooks parameter passed in. Methods: This class should implement the provided interface StoreOrganizer. The getBooks method will return all of the books in the store. There should be a method called add (Book book) that allows the client to pass in a Book which will be added to the books array. Be sure that this method does not allow any books to be added if the array is full. The sort () method should sort the animals in the books variable by using the merge sort method. for a good visual representation as to what merge sort does: https://visualgo.net/bn/sorting. o Make sure to cite any resources referenced when implementing your merge sort algorithm by including them in the Javadoc of any helper methods related to sorting. This class should have a method search (Book book). To search for a book, a client should be able to pass in an instance of a book and the method will return the index of the book, if found, or -1 if it cannot be found. Use the linear search method to search through the books. Click this link for a good visual representation of the linear search method: https://www.cs.usfca.edu/~galles/visualization/Search.html There should be a method called remove (Book book) that allows the client to remove the first occurrence of a Book that matches the one passed in. Make sure to think carefully about the side effects of removing a Book from the middle of an array and assign null to any elements that become "empty" IMPORTANT: You should understand the efficiency of the search and sort methods that you have implemented. Page 7 > of 9 ZOOM Checkstyle You must run checkstyle on your submission. If you don't have checkstyle yet, download it from Canvas Modules -> Checkstyle Resources in the B section and in Modules -> General Information in the A section. Place it in the same folder as the files you want checkstyled. Run checkstyle on your code like so: $ java -jar checkstyle-8.28.jar yourFileName.java Starting audit... Audit done. The message above means there were no Checkstyle errors. If you had any errors, they would show up above this message, and the number at the end would be the points we would take off (limited by the checkstyle cap mentioned in the Rubric section). In future homeworks we will be increasing this cap, so get into the habit of fixing these style errors early! Checkstyle willI be required on this homework, with a MAXIMUM point deduction of 20. Allowed Imports To prevent trivialization of the assignment, you are only allowed to import the following classes: No imports outside of the java.lang package should be used. Feature Restrictions There are a few features and methods in Java that overly simplify the concepts we are trying to teach or break our auto grader. For that reason, do not use any of the following in your final submission: var (the reserved keyword) System.exit System.arraycopy
Step by Step Solution
★★★★★
3.40 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
Bookjava class Book implements Comparable String title int edition double price public BookString td...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
Document Format ( 2 attachments)
6360221b3b0ce_233561.pdf
180 KBs PDF File
6360221b3b0ce_233561.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started