Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing the code for the STORE class. We are supposed to create our

ID: 3640364 • Letter: I

Question

I need help writing the code for the STORE class. We are supposed to create our own linked list structure for it. If someone can get me started with the STORE class that would be great. The full assignment is described below.


----------------------------------------------------------------------------------------------------------
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. I’ll try to tailor the lectures and assignments over the next few weeks to this project.

Bonus: For a 10% bonus on this project, 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

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.


public class Store
{
// The store class should store the location of the store and a list of products in the store.
private String location;

// the store should point to a single product, which in turn points to other products, creating another singly linked list.
private Product firstProduct;

// Objects of type Store should point to another Store, creating a singly linked list.
private Store nextStore;

public Store(String location, Product firstProduct)
{
this.location = location;
this.firstProduct = firstProduct;
}

// returns a reference to the linked list of products
public Product getProducts()
{
return firstProduct;
}

// returns the next store
public Store getNextStore()
{
return nextStore();
}

// return location
public String getLocation()
{
return location;
}

// modify product list
public void setProducts(Product firstProduct)
{
this.firstProduct = firstProduct;
}

// Stores should be stored alphabetically by location name.

// return the reference to the new store list
public static Store addStore(Store list, Store rhs)
{
if(list == null)
{
// store list is empty
return rhs;
}
else if(list.location.compareTo(rhs.location) > 0)
{
// rhs goes in front
rhs.nextStore = list;
return rhs;
}
else
{
// figure out where to add rhs
Store current = list;

while(current.nextStore != null && current.nextStore.compareTo(rhs.nextStore) < 0)
{
current = current.nextStore;
}
current.nextStore = rhs;
return list;
}

}

// return the reference to the modified store list
public static
Store removeStore(Store list, Store rhs)
{
if(list.equals(rhs))
{
// remove first node
return list.nextStore;
}
else
{
// find store to be removed
Store current = list;

while(current.nextStore != null)
{
if(current.nextStore.equals(rhs))
{
current.nextStore = current.nextStore.nextStore;
}
}

return list;
}
}
}


public class Product {}
public class Book extends Product {}
public class Movie extends Product {}
public class Music extends Product {}