Overview: The goal of this project is to construct an inventory system for a boo
ID: 3640209 • Letter: O
Question
Overview: The goal of this project is to construct an inventory system for a book-seller. The book-seller will have three types of products: books, music, and movies, each available across multiple store locations.Details: The system that you will write will be a REPL (Read, Evaluate, Print, Loop) with several options, each available from a main menu:
Add a new store.
Remove a store.
List stores.
Add a new product.
Look up a product.
Purchase product.
Add a new store- This should add a new store to the list of available stores. The menu should prompt for the store’s location. The system should disallow you from adding stores in the same location.
Remove a store- The system should prompt the user for a location, and remove the store in that location. The system should notify the user whether the removal was a success.
List stores- The system should provide a list of stores, sorted alphabetically.
Add a new product- The system should prompt the user for the type of the product. For books, the user should be prompted for the name of the book, the author, the ISBN, and the price. For movies, the user should be prompted for the name of the movie, the year it was released, and the price. For music, the user should be prompted for the name, the artist or group, the genre, and the price. Finally, the system should prompt for each of the store locations- asking the user how many of the product to add at each store.
Find product- The system should prompt the user for the name of the product he or she is searching for. It should then display the information associated with it, depending on what type of product it is, as well as the store locations where it can be found and how many are at each location. (If no such product is found, it should return to the menu.)
Purchase product- The system should prompt the user for the name of the product he or she is searching for. It should then display the information associated with it, depending on what type of product it is, as well as the store locations where it can be found and how many are at each location. (If no such product is found, it should return to the menu.) The system should then ask if the user wants to purchase the product and from which location he or she wishes to purchase it from. That product should then be removed from the system.
Implementation Details
Implementation Description: There is obviously a lot to do here. Your implementation should do all that I described above, using the concepts of object oriented programming and linked lists that you all have learned in class and in lab. For this project, you must write your own data structures. Do not use any built-in Java lists such as arrays or arrayLists.
Your program should use several classes. Book, movie, and music should all be children of the product class.
Store
Product
Book
Movie
Music
Store Class: The store class should store the location of the store and a list of products in the store. Objects of type Store should point to another Store, creating a singly linked list. The store list can be navigated via the pointer to the next store. Additionally, the store should point to a single product, which in turn points to other products, creating another singly linked list. Stores should be stored alphabetically by location name. This requires a little bit of thought when adding and removing stores to the list.
Product Class: Again, the product class should create a singly linked list by pointing to another Product. The product should include the name and price.
Book Class: This should inherit from the product class and should include the author and ISBN. You don’t need to repeat the name or price.
Movie Class: This should inherit from the product class and should include the year released. You don’t need to repeat the name or price.
Music Class: Similarly, this should inherit from the product class and should include the artist and genre. Again, you don’t need to repeat the name or price.
An internal representation of the objects in this project might look like the diagram below. Note the linked structure between all objects. Also note that the stores are sorted alphabetically by their location. Finally, note that there is a HEAD that points to the first store. You don’t necessarily have to use the variable names that are shown in the diagram.
?
Obviously, you’ll need a lot more than just the fields listed above. You’ll also need methods to add different objects to their respective lists, and test whether a product is a book, movie, or music (HINT: instanceof) . It’s up to you to determine how this should be accomplished.
Implement a VIP customer system.
Add the following options to the initial menu:
Add a VIP customer- The system should prompt the user for the name of the customer, and his or her phone number. It should not allow for identical names.
List VIP customers- Lists all of the VIP customers in the system.
When products are looked up or purchased, add a feature where the system prompts for the phone number of the customer. If that phone number belongs to a VIP customer, then add a 10% discount to the price of the product.
This necessitates the following customer class:
Customer Class (Bonus): The customer class should store the name and phone number of the customer. I don’t care how this information is stored (i.e. whether it is Last, First or First_Last). Objects of type Customer should point to another customer, creating another singly linked list. The customer list can be navigated via the pointer to the next customer.
Explanation / Answer
mport java.util.*; class Books{ public String title; public String author; public int isbn; public double price; public double discount; public double total; public Books(){} public Books(String title,String author, int isbn,double price,double discount,double total) { super(); this.title=title; this.author= author; this.isbn = isbn; this.price=price; this.discount=discount; this.total=total; } public String getTitle() { return title; } public String getAuthor() { return author; } public int getIsbn() { return isbn; } public double getPrice() { return price; } public double getDiscount() { return discount; } public double getTotal() { return total; } } public class BookStore { public static void main(String[] args) throws Exception { double amount=0.0; double sum=0.0; int count=1; List list = new ArrayList(); Scanner scan = new Scanner(System.in); int menu = 0; System.out.println("Book Store"); System.out.println(); System.out.println("1. Buy book"); System.out.println("2. Receipt"); System.out.println("3. Receive Payment"); System.out.println("4. Exit"); boolean quit = false; do{ if(count>5){ System.out.println("You cannot buy more than 5 books at a time."); } System.out.print("Please enter your choice: "); menu = scan.nextInt(); System.out.println(); switch(menu) { case 1: count++; System.out.println("Book Title: "); String booktitle = scan.next(); System.out.println("Author: "); String auth = scan.next(); System.out.println("ISBN: "); int no = scan.nextInt(); System.out.println("Price: "); double p = scan.nextDouble(); System.out.println("Discount: "); double dis = scan.nextDouble(); double total=p-(dis*p); list.add(new Books(booktitle,auth,no,p,dis,total)); break; case 2: System.out.println("Title Author ISBN Price Discount Total"); for (Books s : list){ System.out.println(s.getTitle()+" " +s.getAuthor()+" " +s.getIsbn()+" "+s.getPrice()+" " +s.getDiscount()+" " +s.getTotal()); sum+=s.getTotal(); } System.out.println("Total= "+sum); break; case 3: System.out.println("Customer Pays: "); amount = scan.nextDouble(); double balance=amount-sum; System.out.println("Balance is: "+balance); quit = true; case 4: quit = true; break; default: System.out.println("Invalid Entry!"); } } while (!quit); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.