Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please solve this project in JAVA: These are the input files: General Instructions: Go through the problem, UML diagrams and class descriptions carefully. Maintain the

Please solve this project in JAVA:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

These are the input files:

image text in transcribedimage text in transcribedimage text in transcribed

General Instructions: Go through the problem, UML diagrams and class descriptions carefully. Maintain the provided architecture. You may add helper methods and classes, butyou must be able to explain the need of them. If you cannot give a proper explanation, then marks will be deducted. If you add any helper class, add it in a different package named helpers. Use proper naming conventions for naming fields. Most of the IDE's and code editors do proper indentation automatically. So, please use it. Problem: Suppose you are hired by a company to develop an Inventory Management and Billing System for them. The company has categorized their books into two main genres - fiction and non-fiction. As a startup, the company is giving attractive discounts on books to gain more customers. They are giving two kinds of discounts - book-discount and genre-discount. Book-discount is given on a book and may vary from book to book. On the other hand, genrediscount is given on genres of books set by the company. Currently the company gives 9% discount on Fiction and 10% for non-fiction books. There is also another kind of discount named author-discount which is, if someone buys 3 or more books by the same author, he/she will get 45% discount on the price of those books. When billing an invoice, the company compares between the eligible discounts and give the one which is more than the other. The company wants to keep the books sorted according to their ISBN. However, you should also keep the option to sort the books by their price and year published if required. UML Class Diagram is given below. \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Author } \\ \hline - mame: String \\ - emaild: : String \\ - age: int \\ - gender: String \\ \hline + getName') : Sting \\ + geiEmailldO: String \\ + setEmaildd(email : Strird) : void \\ + getGender0: : String \\ + getAge(): irt \\ + setAoctage : irt : void \\ + toStringl: : String \\ \hline \end{tabular} \begin{tabular}{l} Atinterfacess \\ \multicolumn{1}{|c|}{ Comparable } \\ \hline \end{tabular} Class, Method \& Variable Description: Class: Fiction This class will implement the Genre Interface Class: NonFiction This class will implement the Genre interface Class: Book Class: BookCollection To find the quantity of a certain book you wil have to count the number of book objects. \begin{tabular}{|l|l|} \hline addBook(Book): boolean & This method will take a Book object as a parameter, add the book into the books array and return a boolean value, depending on whether the operation was successfully done \\ \hline \end{tabular} \begin{tabular}{|l|l|} \hline & or not. \\ \hline removeBook(int): boolean & This method will take the index of the book you want to remove and remove the book from the bookCollection. It will replace the empty space by shifting the book objects to the left by one index, starting from index +1. \\ \hline getBook(String): Book & Will search for a book, return the book and remove it from the books array. You will pass the isbn number as parameter here. \\ \hline printBookinfo(Book): String & Will search for a book and return a String containing the information of the book. \\ \hline sortBylsbnBooks():void & This method will sort the books in the books array according to their ISBN. Hint: As you implemented the \\ \hline resetBooks():void & compareTo():int method in the Book class you can now compare two elasses with each other. \\ \hline sortByYearOfPublish():void & You can have only one implementation of compareTo():int method in a class. So, you have to write an algorithm to sort. You can use Merge Sort / Quick Sort algorithm. \\ \hline \end{tabular} Class: Invoice \begin{tabular}{|l|l|} \hline & min(a,b,c) \\ \hline getDateTime():String & This method will return the date object formatted in "dd-MM-yyyy HH:mm:ss" pattern \\ \hline calculateBcokDiscountPrice():double & This method calculates and returns the price after giving the book discount, if any. \\ \hline calculateAuthorDiscountPrice():double & This method calculates and returns the price afler giving the author discount, if any. \\ \hline calculateGenreDiscountPrice():double & This method calculates and returns the price after giving the genre discount, if any. \\ \hline ifAuthorDiscountEligable():boolean & This method returns a boolean value, which depends on vihether the author discount is eligible or not. \\ \hline toString():String & This method will return a string, which should have a format like this -Date \& time in "dd-MM-yyyy HH:mm:ss" in this pattem. The name of books in the invoice - and their price. The total price of the books. The price after discount. \\ \hline \end{tabular} Tasks: \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Obiects } \\ \hline NOTE: You must use the provided objects for inputs, else your assignment will not be graded. \\ \hline \end{tabular} \begin{tabular}{|c|c|} \hline Task & \multicolumn{1}{|c|}{ Expected Output } \\ \hline 1. Sort the collection by isbn number and & The Burning Maze, 9123567891201 The Philosopher's stone, 9123567891202 \\ \hline \end{tabular} Author a1 = new Author("John Green", "green@example.com", 42, "male"); Author a2 = new Author("JK Rowling", "rowling@exmaple.com", 54, "fernale"); Author a3 = new Author("Nicholas Sparks", "sparks@exmaple.com", 53, "male"); Author a4 = new Author("Rick Riordan", "riordan@exmaple com", 55, "male"); Author a5 = new Author("Stephen Hawking", "', - 1, "male"); Author a6 = new Author("Dan Brown", "brown@exmaple.com", 55, "male"); Author a7 = new Author("Stephen King", "king@exmaple.com", 72, "male"); Author a8 = new Author("Malcolm Gladwell". "gladwell@exmaple.com", 56, "male"): Author a9 = new Author("Kyo Maclear", "maclear@exmaple.com", 49, "female"); Book bo = new Book("The Burning Maze", 250, a4, 10.6, new Fiction("fantasy"), "9123567891201", 2018); Book b1 = new Book("The Philosopher's Stone", 550, a2, 10.3, new Fiction("fantasy"), "9123567891202". 1997): Book b2 = new Book("The Chamber of Secrets", 450, a2, 10.2, new Fiction("fantasy"), "9123567891203", 1998); Book b3 = new Book("The Prisoner of Azkaban", 330, a2, 8.5, new Fiction("fantasy"), "9123567891204". 1999); Book b4 = new Book("The Goblet of Fire", 300, a2, 7.3, new Fiction("fantasy"), "9123567891205", 2000); Book b5 = new Book("Looking for Alaska", 500, a1, 10.8, new Fiction("Young adult fiction"), "9123567891206", 2005); Book b6 = new Book("Paper Towns", 250, a1, 8, new Fiction("mystry"), "9123567891207", 2008); Book b7 = new Book("A Walk to Remember". 350. a3, 9.5, new Fiction("drama"). "9123567891208", 2002); Book b8 = new Book("The Lightning Thiep", 450, a4, 8.4, new Fiction("fantasy"), "9123567891209", 2005); Book b9 = new Book("The House of Hades", 150, a4, 10.5, new Fiction("fantasy"), "9123567891210", 2013); Book b10 = new Book("Inferno", 450, a6, 10.6, new Fiction("thriller"), "9123567891211", 2013); Book b11 = new Book("Deception point", 550, a6, 10.6, new Fiction("mystry"). "9123567891212", 2001); Book b12 = new Book("angels and demons", 430, a6, 10.5, new Fiction("crime"), "9123567891213", 2000); Book b13 = new Book("Da Vinci Code", 470, a6, 11.5, new Fiction("crime"), "9123567891214", 2000): Book b14 = new Book("Origin", 370, a6, 11.5, new Fiction("crime"), "91235678912115", 2017); Book b15 = new Book("A Brief History of Time", 330, a5, 5.5, new NonFiction("science"), "9123567891216", 1998); Book b16 = new Book("The Theory of Everything", 420, a5, 6.3, new NonFiction("science"), "9123567891217", 2004); Book b17 = new Book("God Created the Integers", 423, a5, 7.2, new NonFiction("biography"). "9123567891218", 2005); Book b18 = new Book("The Green Mile", 270, a7, 11.5, new Fiction("fantasy"), "9123567891219", 1996); Book b19 = new Book("Blink", 423, a8, 7.2, new NonFiction("self-help"), "9123567891220", 2005); Book b20 = new Book("Birds Art Life", 403, a9, 3.0, new NonFiction("biography"), "9123567891221", 2017): //input set for task 1, 2 BookCollection c = new BookCollection(); c.addBook(b0); c.addBook(b5); c.addBook(b1): c.addBook(b3); c.addBook(b4); c.addBook(b2); I/input set for task 3,4,5,6 c= new BookCollection(): c.addBook(b0); c.addBook(b15); c.addBook(b1); c.addBook(b3); c.addBook(b4): c.addBook(b2); c.addBook(b6); c.addBook(b18); c.addBook(b17); c.addBook(b11); c.addBook(b10); c.addBook(b19); c.addBook(b12); c.addBook(b13); c.addBook(b14); c.addBook(b5); c.addBook(b16); c.addBook(b7); c.addBook(b8); c.addBook(b9); c.addBook(b20); //input set for problem 7 Invoice i = new Invoice(); i.addBook(b1); i.addBook(b2); i.addBook(b3); i.addBook(b8); I/input set for problem 8 c= new BookCollection(); c.addBook(b0); c.addBook(b15); c.addBook(b1); c.addBook(b3); c.addBook(b4): c.addB0ok(b2); i = new Invoice(); i.addBook(c.getBook("9123567891201")); i.addBook(c.getBook("9123567891202"))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions