This class represents a physical book in the bookstore (visible or invisible) and should implement an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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: <title>, Edition: <edition>, Price: <insert 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 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: <title>, Edition: <edition>, Price: <insert 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
Expert Answer:
Answer rating: 100% (QA)
Bookjava class Book implements Comparable String title int edition double price public BookString td... View the full answer
Related Book For
Elementary Statistics in Social Research Essentials
ISBN: 9780205638000
3rd edition
Authors: Jack A. Levin, James Alan Fox
Posted Date:
Students also viewed these programming questions
-
Write a Super class interface employee has name and id number. Write manager and labour derived from employee class. Manager class has member data qfunction and qualification and manager allowance...
-
Are order getters more aggressive or creative than order takers? Why or why not?
-
Required a. Name an asset use transaction that will not affect the income statement. b. Name an asset exchange transaction that will affect the statement of cash flows. c. Name an asset source...
-
Create a weighted scoring model to determine grades for a course. Final grades are based on three exams worth 20%, 15%, and 25%, respectively; homework is worth 15%; and a group project is worth 25%....
-
Number of classes: 5 Data set: Pungencies (in thousands of Scoville units) of 24 tabasco peppers Construct a frequency distribution and a frequency histogram for the data set using the indicated...
-
Mountain Equipment Co-op purchased tents for $334.89 less 27%, 18%, and 6%. The store's overhead is 55% of cost and the normal profit is 21% of cost. (a) What is the regular selling price of the...
-
Chicagos OHare Airport handled 67 million passengers last year. As the busiest airport in the world, Atlantas Hartsfield Airport handled 89 million passengers last year. For each pair of values, use...
-
Nino Moscardi, president of Greater Providence Deposit & Trust (GPD&T), received an anonymous note in his mail stating that a bank employee was making bogus loans. Moscardi asked the banks internal...
-
Given: class ArrayDem divya ( { 2-JAN-2024 public static void main(String args[]) int x[] = display(); for (int i=0; i
-
Lang and Thomas, a local CPA firm, has been asked to bid on a contract to perform audits for three counties in its home state. Should the firm be awarded the contract, it must hire one new staff...
-
With you the back is the balance of Al-Tawfiq stores, a set of balances, including 1600 Ruani, 900 shop rent, 1600 stationery, 1000 revenues or financial revenues, 500 pre-received receipts, and on...
-
On the cold and breezy evening of April 26, 2018, Niraj Taksande, director of Expres was sipping hot coffee while contemplating the service delivery model and retail form Should EBW go for self-owned...
-
What is the reason for setting up products or services in QuickBooks Online?
-
Use an Internet search on the acquirer involved in your merger to answer the following: What information is available about merger activity for the acquirer last 5 years not including the merger you...
-
What is Chem - Med s average accounts receivable collection period for 2 0 1 5 , 2 0 1 6 , 2 0 1 7 , 2 0 1 8 ? Is the period getting longer or shorter? What are the consequences?
-
1 . To what extent ( if any ) is Lorne Albaum blameworthy for the Taylor s losses? Please explain your rationale. Assume that TRC Capital is not violating U . S . or Canadian securities law. Under...
-
2) a = -ks Determine k so that vel = 15m/s when s=0 And s=3m when v=0 Determine v when s=2m
-
Prepare a stock card using the following information A company is registered for GST which it pays quarterly, assume GST was last paid on the 30th of June 2019. It uses weighted average cost...
-
To estimate the proportion of troops who support the U.S. militarys Dont Ask, Dont Tell policy of discharging people who are openly homosexual, a political researcher interviewed a random sample of...
-
Suppose that a researcher collected the following set of data on years of education (X) and number of children (Y) for a sample of 10 married adults: X Y 12. 2 14. 1 17. 0 10. 3 8. 5 9. 3 12. 4 14. 2...
-
A focus group of high school students was surveyed about their use of various drugs, including alcohol. Asked how frequently they had been drunk in the previous six months, the students responded:...
-
In the chapter, we mentioned that if Cafe Revive came up short four coffee gift packs, it should increase its cost of goods sold account and decrease its inventory account by the cost of those gift...
-
In terms of the accounting equation, where are changes in revenue and expense accounts recorded?
-
Johnson and Bates run a small business and are worried about their accounts receivable spiralling out of control. a Advise them of the steps they can take to manage credit and recover outstanding...
Study smarter with the SolutionInn App